Written by Emily Leng
How do loops work? Examine the flowchart left for you, then match the letter choices to the correct loop. Submit the result of the loops in the order the diagrams are drawn (without line breaks or spaces) as your solution.
Clarification: the "flag" should be the output of the loops in the order they are shown (without line breaks or spaces), not the letter choices.
Java has several types of loops - for
, for each
, while
, do-while
- how do they differ from each other? And how do flow controls like breaks or switch statements affect how code runs?
The multiple choices for the loops in the order as drawn are:
- B
- A
- C
- E
- F
- D
Their corresponding outputs (without line breaks or spaces) can be logically thought out, run in java, or translated to another language and then run if you don't like java. Anyway, you end up with these:
- 024024024
- 01234
- 07325
- 01234
- 020202
- 0297499161411161614111616131818
0240240240123407325012340202020297499161411161614111616131818