Let’s write an useful C program today. This C Program will convert any Uppercase string to Lowercase.
For this, we are going to use tolower() function which is already available in C itself.
#include <stdio.h>
int main() {
char mystr[100];
int i=0;
//print about the program
printf("C Program to convert uppercase to lowercase\n");
printf("Enter your full name in CAPS: ");
//get the input string from user
fgets(mystr, 100, stdin);
//loop through the string and convert into lower letters
while( mystr[i] ) {
//store back the lower letter to mystr
mystr[i] = tolower(mystr[i]);
i++;
}
//print the lower letters
printf("Lowercase: %s", mystr);
}Read the comments in the above program to understand how it works.
Output of the above program will be:
C Program to convert uppercase to lowercase Enter your full name in CAPS: AGURCHAND BABU Lowercase: agurchand babu
Enjoy the day!