Tip: Choose Save as PDF in the print dialog to download. Use A4 paper size.
Shade in the A or B circle for each question.
Draw a line connecting each item on the left to its match on the right.
| Left column | Right column | |
|---|---|---|
| 1WHILE Count < 5 DO Count ← Count + 1 ENDWHILE | ARuns the body first, then stops as soon as the condition is TRUE, so the body runs at least once | |
| 2REPEAT Count ← Count + 1 UNTIL Count >= 5 | BTotal ← 10 WHILE Total < 5 DO OUTPUT Total ENDWHILE | |
| 3The same task written both ways needs the condition reversed: WHILE continues on TRUE, REPEAT stops on TRUE | CWHILE Num <= 0 DO INPUT Num ENDWHILE REPEAT INPUT Num UNTIL Num > 0 | |
| 4Zero-iteration case: if the condition is already false at the start, a WHILE loop body never runs | DWHILE continues on TRUE, so with the condition copied from an UNTIL line it exits straight away or never runs. It should be WHILE Count < 10 DO. | |
| 5REPEAT INPUT Password UNTIL Password <> "abc" | EREPEAT stops when the condition is TRUE, so this stops on a wrong password. The condition was not reversed: it should be UNTIL Password = "abc". | |
| 6WHILE Count = 10 DO Count ← Count + 1 ENDWHILE | FTests the condition first and keeps looping while it is TRUE, so the body may run zero times |
Complete each line of code by filling in the missing parts.
Shade in the letter of the line that contains an error.
WHILE vs REPEAT — WHILE tests first, so its body may never run, and it loops while the condition is TRUE. REPEAT tests after the body, so it runs at least once, and it stops when the condition is TRUE.WHILE Num < 10 DO
Num ← Num + 1
ENDWHILEREPEAT
Num ← Num + 1
UNTIL Num >= 10WHILE FALSE DO
OUTPUT "Hi"
ENDWHILEREPEAT
OUTPUT "Hi"
UNTIL TRUEREPEAT
INPUT Age
UNTIL Age >= 0