while Loops

AP Computer Science A· difficulty 3/5

<code>int i = 1; while (i < 16) i *= 2;</code> — final i and iterations

  • A

    i=16, 5 iterations

  • B

    i=32, 5 iterations

  • C

    i=16, 4 iterations

    check_circle
  • D

    i=8, 3 iterations

Explanation

1 → 2 → 4 → 8 → 16 (4 multiplications); condition fails at 16.

Want 10 more like this — adaptive to your weak spots?

Related questions