Output Writing – isupper(), islower, isalpha() – CSKC
Sign In

Search

Solved Problem! #CPP#2677    siteicon   siteicon  

Problem Statement - Output Writing – isupper(), islower, isalpha()

Write output of the following program.

TC++ #2677

 

×

Ask AI About This Code

Default Prompt that is passed along with the code is given below, You can write your own prompt if you so desire.



×

Test CPP

Solution


char str[21]=”C++ Programming”;  //Initialised string in char array.

int len=strlen(str); //Length will be found here. The length will actually be number characters in the given initial string and not the array size, as it is null terminated string.
while(len>0)
This loop will run until the len value is reduced to zero, Hence it should be a decrement loop
{

if(isupper(str[len-1])) str[len-1]=’@’;
It starts checking from last character. If the character is upper case it is changed to @

else if(islower(str[len-1])) str[len-1]=’#’;
If lowercase it is changed to # character

else if(!isalpha(str[len-1])) str[len-1]=’%’;
All non-alphabet characters are changed to %. this means that ++ and space after that will be changed to %%%
len–;
len is decremented so that loop keeps running till first character which is index 0 location of the character array.
}

Common Errors

  • These program need patience and right understanding. Student often miss converting space also as a non alphabet.


Share

Created: 16-Jan-2018 23:14 | Updated: 17-Jan-2018 19:16|