0

How to do attempt isupper to islower like questions ?

Find the output : #include<iostream> #include<ctype> void changeIt(char Text[], char C) { for(int K=0,Text[K]!='\0';K++) { if(Text[K] >='F' && Text[K]<='L') Text[K]=tolower(Text[K]); else if(Text[K]=='E' || Text[K] =='e') Text[K] =C; else if(K%2==0) Text[K]=toupper(Text[K]); else Text[K]=Text[K-1]; } } void main() { char Old Text[] ="pOweRALone"; changeIt(oldText,'%') ; cout<<"New Text:<<OldText<<endl; }

26th Mar 2017, 6:52 AM
Abdul Khan
2 Respuestas
+ 1
Internal char literal are stored and managed as integers, Whenever a character is entered in char variable, its ASCII code is stored in actual. In ASCII table, 'A' is at index 65 and 'a' is at index 97, thus there exist a difference of 32 between Capital and small version of the same character. This can be easily used for converting to lower to upper case and vice versa 1. Logic of isupper(char) function as follows if (ch >= 'A' && ch <= 'Z') { return true; }else{ return false; } 2. Logic of islower(char) function as follows if (ch >= 'a' && ch <= 'z') { return true; }else{ return false; } 3. Logic of tolower(char) function as follows if (ch >= 'A' && ch <= 'Z') { ch += 32; } 4. Logic of toupper(char) function as follows if (ch >= 'a' && ch <= 'z') { ch -= 32; }
26th Mar 2017, 7:13 AM
देवेंद्र महाजन (Devender)
देवेंद्र महाजन (Devender) - avatar
0
output?
26th Mar 2017, 1:44 PM
Abdul Khan