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 X < 10 DO ... ENDWHILE becomes REPEAT ... UNTIL X >= 10 | AUNTIL Count = 5 | |
| 2X <- 20 REPEAT X <- X + 1 UNTIL X >= 10 | BThe REPEAT...UNTIL X >= 10 condition was copied into WHILE without being reversed, so the loop will not run when X starts below 10. It should be WHILE X < 10. | |
| 3A WHILE loop that runs while Count <> 5 is converted to REPEAT...UNTIL by reversing the condition to equal | CThe body runs once even though the condition is already TRUE at the start, so X ends as 21 | |
| 4To copy a WHILE loop's behaviour with REPEAT...UNTIL when the condition may start FALSE, wrap the REPEAT loop in an IF with the original condition | DIF X < 10 THEN REPEAT X <- X + 1 UNTIL X >= 10 ENDIF | |
| 5REPEAT X <- X + 1 UNTIL X < 10 | EConverting a WHILE loop to REPEAT...UNTIL means reversing the condition: the loop now stops when X >= 10 is TRUE | |
| 6WHILE X >= 10 DO X <- X + 1 ENDWHILE | FThe condition was copied from WHILE X < 10 and not reversed, so UNTIL X < 10 is the wrong way round. It should be UNTIL X >= 10. |
Complete each line of code by filling in the missing parts.
Shade in the letter of the line that contains an error.
UNTIL X >= 10 — Reverses WHILE X < 10. WHILE loops while TRUE, UNTIL stops when TRUE, so flip the condition. REPEAT also runs its body once before the first test.REPEAT
X ← X + 1
UNTIL X >= 10WHILE X < 10 DO
X ← X + 1
ENDWHILEWHILE Count <> 5 DO
Count ← Count + 1
ENDWHILEREPEAT
INPUT Num
UNTIL Num > 0REPEAT
OUTPUT X
UNTIL X >= 10