First the ps: You don't need code blocks around a single statement, so the following:
1 2 3 4 5 6 7 8 9
x = 3;
if( someCondition)
doThis();
y = 4;
if( someOtherCondition)
{
doThis();
doThat(x, y);
}
if line 2 is true, it will only execute the next single statement, which is doThis();, the brackets on line 6 tell the if statement to do multiply statements if it evaluates to true.
Now, to explain your code: There are several functions, bool isLower(char) checks if a character is lower case, char toUpper(char) returns an upper case character, with the other 2 functions doing the opposite of that. With that, you should be able to figure out what the code does.
You don't need code blocks around a single statement
While you certainly don't need them, I don't recommend doing this. There is no harm in putting braces around a single line if, unless you're in some deranged competition where you win by having the least lines of code.
1 2 3 4 5 6 7 8 9 10
if(someCondition)
doThis();
y = 4;
if(someCondition)
{
doThis();
y = 4
}
The two if-statements look nearly identical thanks to incorrect identation, but behave differently thanks to the braces (or lack thereof). A novice may be hard-pressed to know *why* if they are looking at a snippet of code that is causing problems.
Thnx for all of your help.
Found that the output will be A OROoIiE.
For eg:
The letter P is stored in NAME[2]...
Since it is already upper , it is either converted into lowercase of the last character or it is decremented entirely.
Since x=2, x%2!=0 renders false and hence , the character gets decremented.
SO P becomes O.
The letter F is stored in NAME[5].
It is upper case and x%2!=0 renders true. Hence it is converted into the lowercase of the previous character which is o.
If the character is lowercase , it is simply converted to uppercase.