Question 5
Back to Exercise
What is the value of i after int i = 5; i = i++;?
- A 5
- B 6
- C Undefined behaviour – i is modified twice without a sequence point Correct
- D 7
Correct Answer: Option C
The assignment and the increment both modify i, and C does not order them. Some compilers give 5, others 6, and optimisers may do anything else. Clang warns "multiple unsequenced modifications to i".
Discussion & Comments 0
Share your method, a shortcut, or ask about a step you didn't follow.
No comments yet. Be the first to share your solution!