Bitkernel · CS Fundamentals
Evaluate C for-loop execution count
TrueInterview
October 7, 2026 · 1 min read
In C, the variables m and n both have type int. Take a look at this code:
int m, n;
for (m = 0, n = -1; n = 0; m++, n++)
n++;
Under standard C semantics (where = performs assignment rather than comparison), how many times is the loop body (n++ inside the loop) executed?
Options:
- A. The loop body executes 0 times
- B. The loop body executes 1 time
- C. The loop is infinite
- D. There is a runtime error Overview: This question tests knowledge of C expression evaluation and control-flow semantics, specifically how assignment expressions interact with loop conditions and variable updates.
Loading comments…