Question { TCS, 6330 }
How to convert lowercase letters to uppercase and uppercase letters to lowercase in a string. (ex, AbcdEfG should convert as aBCDeFg)
Answer
easiest way is to use the condition-
for(i=0;s[i]!='';i++)
{
if(s[i]>=65 && s[i]<=90) //Caps ASCII-65-90(60+32=97-----90+32=122)
s[i]=s[i]+32;
if(s[i]>=97 && s[i]<=122) // Small ASCII-97-122(97-32=65-----122-32=90)
s[i]=s[i]-32;
}