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 < 3 DO | AThe condition is tested before the body, so the loop may run zero times. Check it before every pass. | |
| 2UNTIL Total >= 10 | BTotal ← Total + Count | |
| 3A FOR loop trace has one row per pass, with the counter taking each value from start to end | CFOR Count ← 1 TO 4 | |
| 4Record a changed value in a new row each pass, such as a running total going up | DThe condition is tested after the body, so the loop always runs at least once. Stop when it becomes true. | |
| 5Trace of REPEAT ... UNTIL Count = 3: test Count = 3 before running the body the first time | EA REPEAT loop tests its condition after the body, not before. The body must run once first. | |
| 6Trace of FOR Count ← 1 TO 3: stop the table after the row where Count = 2 | FThe final row was not checked. The loop runs for Count = 3 too, so the last row is missing. |
Complete each line of code by filling in the missing parts.
Shade in the letter of the line that contains an error.
Tracing a loop — Work through the loop body once per pass, recording changed values in a new row each time. Test the condition before the body for WHILE and after it for REPEAT. Check the final row.FOR Count ← 1 TO 4
OUTPUT Count
NEXT CountWHILE Num < 3 DO
Num ← Num + 1
ENDWHILEREPEAT
Num ← Num + 2
UNTIL Num >= 7FOR Count ← 1 TO 3
Total ← Total + Count
NEXT CountWHILE Num < 10 DO
Num ← Num * 2
ENDWHILE