Multiple choice

int x = 0; for ( ; ; ) { if (x++ == 4) break; continue; } printf(x=%dn, x);

What will be printed when the sample code above is executed?

  1. x = 0

  2. x = 1

  3. x = 4

  4. x = 5

  5. x = 6

Reveal answer Fill a bubble to check yourself
D Correct answer
Explanation

The loop uses post-increment (x++), which means the current value is compared first, then x is incremented. When x=4, the condition (x++4) is true (44), then x becomes 5, and the break executes. The printf shows x=5, not x=4, because the increment happens after the comparison.