ProgrammingModerateTCS NQT · Infosys pattern

What is printed?

What is printed?
int i = 5;
size_t s = sizeof(i++);
printf("%zu %d", s, i);          /* 4-byte int */
  1. A. 4 5
  2. B. 4 6
  3. C. 8 5
  4. D. 5 5

Correct answer: A. 4 5

sizeof is evaluated at compile time from the type of its operand; the expression i++ is never executed (except for variable-length arrays), so i stays 5.

More C Programming questions

Exams that ask this topic