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 | |
|---|---|---|
| 1FOR i <- 1 TO 10 IF i MOD 2 = 0 THEN Count <- Count + 1 ENDIF NEXT i | ACounts the even numbers from 1 to 10. The IF is tested on every pass, so Count only goes up when i is even. | |
| 2WHILE Num <> -1 IF Num > 50 THEN Total <- Total + Num ENDIF INPUT Num ENDWHILE | BThe loop and the selection overlap. NEXT i is inside the IF, so the ENDIF must come before NEXT i. A structure inside a loop must be fully closed before the loop ends. | |
| 3A selection inside a REPEAT...UNTIL loop is checked on every repeat, so each input can be handled differently, such as counting only passes. | CThe IF is placed after NEXT, so it is outside the loop. It is only tested once, not on every pass. The IF must be moved inside the loop, before NEXT i. | |
| 4A CASE statement inside a FOR loop chooses a different branch on each pass, depending on the current value of the counter. | DKeeps reading numbers until -1 is entered and adds only the numbers over 50 to Total. | |
| 5FOR i <- 1 TO 10 NEXT i IF i MOD 2 = 0 THEN Count <- Count + 1 ENDIF | EREPEAT INPUT Mark IF Mark >= 50 THEN Passes <- Passes + 1 ENDIF UNTIL Mark = -1 | |
| 6FOR i <- 1 TO 10 IF i MOD 2 = 0 THEN Total <- Total + i NEXT i ENDIF | FFOR Day <- 1 TO 7 CASE OF Day 6, 7 : OUTPUT "Weekend" OTHERWISE : OUTPUT "Weekday" ENDCASE NEXT Day |
Complete each line of code by filling in the missing parts.
Shade in the letter of the line that contains an error.
IF inside a loop — An IF or CASE placed in a loop body is tested again on every repeat, so each pass can take a different branch depending on the current value.FOR Num ← 1 TO 20
IF Num MOD 2 = 0 THEN
Count ← Count + 1WHILE Count < 5 DO
INPUT Mark
IF Mark >= 50 THENREPEAT
INPUT Num
IF Num > 0 THEN Total ← Total + NumFOR Day ← 1 TO 7
CASE OF Day
1 : OUTPUT "Monday"FOR Num ← 1 TO 10
IF Num > 5 THEN Total ← Total + Num
NEXT Num