ProgrammingHard

int i = 0, j = 10, cnt = 0; while (i < j) { i++; j--; cnt++; } printf("%d", cnt); What is printed?

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

Correct answer: B. 5

Each pass moves the two indices toward each other, and they meet after five passes.

More C Programming questions

Exams that ask this topic