ProgrammingHardWipro NLTH · C

What is printed?

What is printed?
int i, j;
for (i = 0, j = 5; i < j; i++, j--)
    ;
printf("%d %d", i, j);
  1. A. 2 3
  2. B. 3 3
  3. C. 3 2
  4. D. 4 1

Correct answer: C. 3 2

The pairs go (0,5), (1,4), (2,3), (3,2); at (2,3) i < j still holds so both change once more, and then 3 < 2 fails.

More C Programming questions

Exams that ask this topic