Thursday, 11 February 2016

Consider the two C++ statements that follow

Leave a Comment

Consider the two C++ statements that follow:

          char grade = 65;

          char grade = 'A';

    Are they equivalent?


Ans:
The two statements are not really equivalent, although they have the same effect on some systems. Most importantly, the first statement assigns the letter A to grade only on a system using the ASCII code, while the second statement also works for other codes. Second, 65 is a type int constant, whereas 'A' is a type char constant.

Reference:

Answers to Chapter Reviews C++ Primer Plus

If You Enjoyed This, Take 5 Seconds To Share It