ProgrammingModerate

A loop with i starting at 1 and i *= 2 until i > n runs how many times for n = 1000?

  1. A. 9
  2. B. 11
  3. C. 10
  4. D. 1000

Correct answer: C. 10

The values 1, 2, 4, ..., 512 are visited, which is 10 values; the next value 1024 exceeds 1000.

More C Programming questions

Exams that ask this topic