Toggle Case in String – C Program

Toggle Case in String – C Program

write a c program to convert upper case string to lower case string and lower case string to upper case string.

#include<stdio.h>
#include<conio.h>

void main()
{
 char str[100];
 int i;
 clrscr();
 printf("Please, Enter the String =");

//gets(str); 
gets(str);
 
 for(i=0;str[i]!=NULL;i++)
 {
  if(str[i]>='A'&&str[i]<='Z')
   str[i]+=32;
  else if(str[i]>='a'&&str[i]<='z')
   str[i]-=32;
 }
 
 printf("\nThe toggle case string is =  %s",str);

getch();

}

The output of toggle string program is:

Please, Enter the String = Meera Academy

The toggle case string is = mEERA aCADEMY

 

2 thoughts on “Toggle Case in String – C Program

Leave a Reply

Your email address will not be published. Required fields are marked *