ProgrammingHardProduct-company MCQ pattern

With 4-byte int, what is printed?

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

Correct answer: C. 5 4

sizeof does not evaluate its operand (unless it is a variable-length array); it only needs the type. So i++ never executes: i stays 5, and sizeof(int) is 4.

More C Programming questions

Exams that ask this topic