The key to the solution is 'Character is treated as Int while doing arithmetic operations.'
When line 5 x=x+1; gets executed, the Ascii Value of 'x' is added to 1 and the result is an integer.
An integer value cannot be assigned to a char without explicit down casting so the correct way to increment the value of 'x' would be,
x=char (x+1);
Congrats to
1. Joe Smith
for getting the correct answer.
No comments:
Post a Comment
Solution for this question?