ProgrammingHard

int c = 0; for (int i = 0; i < 5; i++) { if (i == 2) continue; if (i == 4) break; c += i; } printf("%d", c); What is printed?

  1. A. 7
  2. B. 10
  3. C. 6
  4. D. 4

Correct answer: D. 4

i = 0, 1 and 3 add to c, since i = 2 is skipped and i = 4 breaks out. The sum is 0 + 1 + 3 = 4.

More C Programming questions

Exams that ask this topic