0

Can anyone solve this, lemme know the process & answer.

Give the output of the following program segment: char *NAME = "IntRAneT"; for (int x = 0; x<strlen(NAME);x++) if(islower(NAME)) NAME[x]=toupper(NAME[x]); else if (isupper(NAME[x])) if (x%2==0) NAME[x]=tolower(NAME[x]); else NAME [x] = NAME[x - 1]; puts(NAME);

16th Jun 2017, 1:13 AM
nitesh kumar
nitesh kumar - avatar
1 Resposta
0
change the declaration to "char NAME[10]" there will be a little problem with ur previous declaration when u treat it as a string for the program to run fine, the third line should be "if(islower(NAME[x]))" if u do these changes then ur output should come like " iNTTaNEE " process of working is simple. if the letter is inlower case, it is converted to upper case. if the letter is upper then, the program looks at the position of the letter in array. if the position number ( ie. '[x]' in ur case ) is perfectly divisible by two...then the letter is converted to lower case. if the position number is not perfectly divisible by two...then the letter in tht position is changed to the letter previous to tht....tht is the reason u hav 2 'T's and 2 'E's in the output. hope this answer helped. keep coding
17th Jun 2017, 1:25 AM
Vyshak Shetty
Vyshak Shetty - avatar