Here is source code of the C program to replace lowercase characters by uppercase & vice-versa. The C program is successfully compiled and run on a Linux system. The program output is also shown below.
* C program to read an English sentence and replace
* lowercase characters by uppercase and vice-versa.
* Output the given sentence as well as the converted
* sentence on two different lines.
int count, ch, i;
printf("Enter a sentence \n");
for (i = 0; (sentence[i] = getchar()) != '\n'; i++)
sentence[i] = '\0';
/* shows the number of chars accepted in a sentence */
count = i;
printf("The given sentence is : %s", sentence);
printf("\n Case changed sentence is: ");
for (i = 0; i < count; i++)
ch = islower(sentence[i])? toupper(sentence[i]) :
$ cc pgm30.c $ a.out Enter a sentence wELCOME tO sANFOUNDRY The given sentence is : wELCOME tO sANFOUNDRY Case changed sentence is: Welcome To Sanfoundry
Sanfoundry Global Education & Learning Series – 1000 C Programs.