Pages1

Answers: computing fundamental with printf

For questions against these answers click here
1. Ans : a
Reason : 51 is the value for ASCII character 3. When we print using "%c" the 51 is
interpreted as the value for the corresponding ASCII character and 3 is printed.

2. Ans : c
Reason :. ASCII value of 1 is 49. When printed as a decimal using conversion specifier
%d, the corresponding contents in the location are just treated as a numeric value and
hence 49 is printed.

3. Ans : b
Reason : ASCII value of 2 is 50 and of 1 is 49. When the two are subtracted, 1 is obtained
which is printed as a decimal using conversion specifier %d. Try printing the same thing
using %c and you will notice that since 1 is not part of the ASCII character set some nonrecognizable
character may appear on the screen.

4. Ans : a
Reason : ASCII value of '1' is 49. When numeric 1 is added, it results in 50 which is
nothing but the ASCII value of 2. Hence printing using conversion specifier %c would
print 2.

5. Ans : c
Reason : ASCII value of '1' is 49. When numeric 1 is added to this, it results in 50.
Hence printing using conversion specifier %x would print 32 (0x32=50).

No comments:

Post a Comment