Nathan won the man of the match award in the recently concluded local tournament final. So the friends of nathan have asked him to take them to cinemas as a trat for winning man of the match.But Nathan is short of money to take them to cinemas so to postpone the cinema plan he tred to engage them with the programming challenge. The task was if the string S was given they have to change the string according to the following condition:If the first letter in a string is capital letter then change the full string to capital letters.
#include <stdio.h>
#include<string.h>
#include<ctype.h>
int main()
{
char s[100];
int n,i;
scanf("%d",&n);
for(i=0;i<n;i++)
{
scanf("%s", s);
int j=0;
if(isupper(s[0]))
{
while (s[j]) {
s[j]=toupper(s[j]);
j++;
}
}
if(islower(s[0]))
{
while (s[j]) {
s[j]=tolower(s[j]);
j++;
}
}
printf("%s\n", s);
}
return 0;
}
Comments
Post a Comment