ProgrammingHard

int i = 0, c = 0; while (i * i < 50) { c++; i++; } printf("%d", c); What is printed?

  1. A. 7
  2. B. 50
  3. C. 8
  4. D. 64

Correct answer: C. 8

The body runs for i = 0..7 (49 < 50) and stops when i = 8 gives 64, so c = 8 because counting starts at i = 0. 7 forgets the i = 0 pass, 50 reads the test as i < 50, and 64 is the failing value of i * i, not the count.

More C Programming questions

Exams that ask this topic