Developing Algorithms Using Strings

AP Computer Science A· difficulty 3/5

<code>while (i < 10) { ... }</code> can be refactored to a <code>for</code> loop as

  • A

    for (i = 0; i < 10; ) { ... }

  • B

    for (; i < 10; ) { ... }

  • C

    All of these (with the same body)

    check_circle
  • D

    for (int i = 0; i < 10; ) { ... }

Explanation

All three forms compile; semantics depend on whether i is already declared.

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

Related questions