5.116 · exercise
Intermediate quiz: loops
Loops inside loops, leaving a loop early, reading until the input runs out, counting passes, and the bugs a call inside a loop body can cause.
0 of 8 correct
Multiple choice
Nested loops print a grid of 3 rows and 4 columns. Where must the inner counter be set back to 0?
Multiple choice
In C, break leaves a loop early. What does it become in assembly?
Multiple choice
A loop ends with cmp w19, w20, then bl printf, then b.lt again. Why can the b.lt go the wrong way?
Multiple choice
A loop reads numbers with scanf until the input runs out. What should it test after each call?
Multiple choice
How many passes does for (i = 0; i < 10; i += 3) make?
Multiple choice
A do-while loop runs while i < n, with i starting at 0. What goes wrong when n is 0?
Multiple choice
A countdown should run its body while w19 is not 0, with no cmp. Which pair of lines ends each pass?
Multiple choice
A loop calls printf on every pass. Why does ldr x0, =fmt_out sit inside the loop, not above it?