ProgrammingHardTCS NQT · Infosys

int x = 5; x = x++; What is the outcome of this statement?

  1. A. x becomes 6
  2. B. x becomes 5
  3. C. undefined behaviour
  4. D. x becomes 7

Correct answer: C. undefined behaviour

x is modified twice between sequence points, once by the increment and once by the assignment, so the standard gives no defined result. Compilers may print any value.

More C Programming questions

Exams that ask this topic