Header Ads Widget

Toggle String

Problem:-

You have been given a String S consisting of uppercase and lowercase English alphabets. You need to change the case of each alphabet in this String. That is, all the uppercase letters should be converted to lowercase and all the lowercase letters should be converted to uppercase. You need to then print the resultant String to output.
Input Format
The first and only line of input contains the String S
Output Format
Print the resultant String on a single line.
Constraints
1|S|100 where S denotes the length of string S.
SAMPLE INPUT
 
abcdE
SAMPLE OUTPUT
 
ABCDe
Time Limit:5.0 sec(s) for each input file.
Memory Limit:256 MB
Source Limit:1024 KB

Solution:-  

#include<string.h>
void main()
{
char s[100],c;
int i,x,l;
scanf("%s",s);
l=strlen(s);
for(i=0;i<=l-1;i++)
{
x=s[i];
if(x<=90)
x=x+32;
else
x=x-32;
c=x;
s[i]=c;
}
printf("%s",s);
}

Post a Comment

0 Comments