ProgrammingHardProduct-company MCQ pattern

With ASCII and 4-byte int, what is printed?

With ASCII and 4-byte int, what is printed?
char c = 'A';
c = c + 32;
printf("%c %zu", c, sizeof(c + 1));
  1. A. 97 1
  2. B. a 4
  3. C. A 4
  4. D. a 1

Correct answer: B. a 4

'A' + 32 = 97 = 'a', stored back in c. In c + 1 the char is promoted to int before the addition, so the expression has type int and sizeof gives 4, not 1.

More C Programming questions

Exams that ask this topic