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 Count ← 1 TO 10 IF Count MOD 2 = 0 THEN OUTPUT Count ENDIF NEXT Count | AFOR Index ← 1 TO 30 IF Mark[Index] >= 50 THEN Passes ← Passes + 1 ENDIF NEXT Index | |
| 2WHILE Number <> 0 DO IF Number > 50 THEN Total ← Total + 1 ENDIF ENDWHILE | BOn each pass of the WHILE loop the IF checks the condition and adds 1 to the counter only when it is true | |
| 3To count how many marks are 50 or more, put an IF inside the loop that adds 1 to a counter when the condition is true | CCount ← 0 is inside the loop, so the counter is reset on every pass and the final count is wrong. Set it to zero once before the loop. | |
| 4Each pass of the loop can take a different branch because the IF is tested again every time round | DThe ENDIF is missing, so the IF inside the loop is not closed before NEXT. Add ENDIF after the THEN statement. | |
| 5FOR Index ← 1 TO 10 Count ← 0 IF Score[Index] > 80 THEN Count ← Count + 1 ENDIF NEXT Index | EFOR Day ← 1 TO 7 IF Rain[Day] > 10 THEN OUTPUT "Wet" ELSE OUTPUT "Dry" ENDIF NEXT Day | |
| 6FOR Index ← 1 TO 10 IF Score[Index] > 80 THEN Count ← Count + 1 NEXT Index | FThe IF is tested on every pass of the FOR loop, so only the even numbers are output |
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 placed inside a loop body is tested again on every pass, so each pass can take a different branch. It is often used to count items that meet a condition.FOR Index ← 1 TO 10
IF Score[Index] > 50 THEN
Passes ← Passes + 1FOR Index ← 1 TO 10
IF Score[Index] > 50 THEN
Passes ← Passes + 1WHILE Index <= 10 DO
IF Temp[Index] > 30 THEN
Hot ← Hot + 1FOR Num ← 1 TO 20
IF Num MOD 2 = 0 THEN
Evens ← Evens + 1FOR Index ← 1 TO 10
IF Mark[Index] >= 40 AND
Mark[Index] <= 60 THEN
Middle ← Middle + 1