ProgrammingVery hardProduct-company MCQ pattern

What is printed?

What is printed?
int x = 5;
x = x++ + 1;
printf("%d", x);
  1. A. 6
  2. B. 7
  3. C. 5
  4. D. Undefined behavior: x is modified more than once without a sequence point

Correct answer: D. Undefined behavior: x is modified more than once without a sequence point

x++ modifies x, and the outer assignment also modifies x, with no sequence point ordering the two writes to the same scalar object. This is classic undefined behavior, not reliably 6.

More C Programming questions

Exams that ask this topic