ProgrammingVery hard

int x = 1, c = 0; while (x < 1000000000) { x *= 3; c++; } printf("%d", c); What is printed (no overflow occurs)?

  1. A. 18
  2. B. 20
  3. C. 9
  4. D. 19

Correct answer: D. 19

3^19 = 1162261467 is the first power of 3 that reaches 10^9, so the loop body runs 19 times.

More C Programming questions

Exams that ask this topic