🔴 Class 65 : Program to convert input string from lower case to upper case and vice versa

Опубликовано: 16 Июль 2026
на канале: Eagles Tech with AI
333
10

#include stdio.h
#include string.h
#include ctype.h

int main()
{

char str[100];
int ctr, ch, i;
printf("\n\nReplace lowercase by uppercase:\n"); // Display information about the task
printf("--------------------------\n");
printf("Input the string : ");
gets(str);
ctr = strlen(str);
printf("\nThe given sentence is : %s", str);
printf("\nAfter Case changed the string is: ");
for (i = 0; i (less than symbol)ctr; i++)
{
// Check if the character is lowercase, then convert to uppercase, else convert to lowercase
ch = islower(str[i]) ? toupper(str[i]) : tolower(str[i]);
putchar(ch); // Output the modified character
}
printf("\n\n");
return 0; // Return 0 to indicate successful execution of the program
}