C Program to convert uppercase string to lowercase string

C Program to convert uppercase string to lowercase string

C Program to convert uppercase string to lowercase string

Program Logic:

The logic we have used in the program is:

All the upper case characters (A-Z) have ASCII value ranging from 65 to 90 and their corresponding lower case characters (a-z) have ASCII value 32 greater than them.

For example ‘A‘ has a ASCII value 65 and ‘a‘ has a ASCII value 97 (65+32). Same applies for other characters.

#include<stdio.h>
#include<string.h>
int main(){
   /* This array can hold a string of upto 35
    * chars, if you are going to enter larger string
    * then increase the array size accordingly
    */
   char str[35];
   int i;
   printf("Enter the string: ");
   scanf("%s",str);
 
   for(i=0;i<=strlen(str);i++){
      if(str[i]>=65&&str[i]<=90)
         str[i]=str[i]+32;
   }
   printf("\nLower Case String is: %s",str);
   return 0;
}

Similar Program:

C Program to convert uppercase string to lowercase string

For any query or issue, feel free to discuss on http://discuss.eduguru.in