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 | |
|---|---|---|
| 1DECLARE Count : INTEGER | AREPEAT INPUT Num IF Num <> -1 THEN Count ← Count + 1 UNTIL Num = -1 | |
| 2Count ← Count + 1 | BCount ← 0 | |
| 3The counter must be set to zero before the loop starts so counting begins from nothing | CCreates an integer variable called Count to hold the number of times something happens | |
| 4A REPEAT loop that counts how many numbers are entered before the sentinel -1 is typed | DCount is reset to 0 inside the loop, so it is wiped on every pass and ends as 1. Count ← 0 must go before the loop. | |
| 5FOR i ← 1 TO 10 Count ← 0 Count ← Count + 1 NEXT i | EAdds 1 to the current value of Count each time this line runs inside the loop | |
| 6Count ← 0 WHILE Num <> -1 DO INPUT Num Count ← Count ENDWHILE | FCount ← Count never changes the counter. It must be Count ← Count + 1 so that 1 is added on each pass. |
Complete each line of code by filling in the missing parts.
Shade in the letter of the line that contains an error.
Count ← Count + 1 — Adds 1 to the counter variable Count each time it runs inside a loop. Set Count ← 0 before the loop starts, so Count ends up holding how many times the loop ran.DECLARE Count : INTEGER
Count ← 0Count ← 0
FOR Index ← 1 TO 5
Count ← Count + 1FOR Index ← 1 TO 10
Count ← Count + 1
NEXT IndexWHILE Num <> -1 DO
Count ← Count + 1
ENDWHILEREPEAT
Count ← Count + 1
UNTIL Num = -1