ProgrammingEasyTCS NQT · Infosys pattern

What is printed?

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

Correct answer: A. 0 3 6 9

i takes 0, 3, 6, 9; the next value 12 fails i < 10, so the loop stops after printing 9. Four iterations in all.

More C Programming questions

Exams that ask this topic