Convert Uppercase to Lowercase in C Without String Convert Function



Before going to know about how to convert upper case to lower case letters without string convert function.

Let us have a look on program to convert upper to lower using convert function, then you will get a clarity on what we are doing in the program −

Example

#include <stdio.h>
#include <string.h>
int main(){
   char string[50];
   printf("enter a string to convert to lower case
");    gets(string); /reading the string    printf("The string in lower case: %s
", strlwr(string)); //strlwr converts all upper    to    lower    return 0; }

Output

enter a string to convert to lower case
CProgramming LangUage
The string in lower case: cprogramming language

Now let's see the program to convert upper to lower without using predefined function −

Example

#include<stdio.h>
void main(){
   //Declaring variable for For loop (to read each position of alphabet) and string//
   int i;
   char string[40];
   //Reading string//
   printf("Enter the string : ");
   gets(string);
   //For loop to read each alphabet//
   for(i=0;string[i]!='\0';i++){
      if(string[i]>=65&&string[i]<=90){
         string[i]=string[i]+32;
      }
   }
   printf("The converted lower case string is : ");
   puts(string);
}

Output

Enter the string : TUTORIALSPOINT
The converted lower case string is : tutorialspoint
Updated on: 2021-03-09T08:57:45+05:30

9K+ Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements