What is the difference in C++ statements.

Q4. How are the following statements in the same set different?

i. char pcode = 75;

char pcode = ‘K’;

ii. char pcode = 75;

short pcode = 75;

iii. const int a = 5;

const a =5;

Ans.(i). Both these statements are equivalent as ASCII value of ‘K’ is 75 and it is 75 only that will be stored in the memory thus pcode = 75 or pcode = ‘K’ mean the same thing.

Ans.(ii). Represented by their associated ASCII codes.

Ans.(iii). No difference. In constant declaration when data types is skipped, by default it is int.

Leave a Reply

Your email address will not be published. Required fields are marked *

355 Views
%d bloggers like this: