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 Found = FALSE AND Index <= 10 DO | AThe REPEAT loop stops when the target is found or the end of the list is passed | |
| 2UNTIL Found = TRUE OR Index > 10 | BOR keeps the loop running while either condition is true, so after the target is found the loop carries on to the end of the list. It should use AND so the loop stops as soon as Found is TRUE. | |
| 3Save the position where the target was found so it can be output after the loop ends | CIF Numbers[Index] = Target THEN Found ← TRUE Position ← Index ENDIF | |
| 4Move on to the next item in the list each time round a WHILE loop | DKeep looping only while the target has not been found and the end of the list has not been reached | |
| 5WHILE Found = FALSE OR Index <= 10 DO | EIndex ← Index + 1 | |
| 6WHILE Found = FALSE AND Index <= 10 DO IF Numbers[Index] = Target THEN Found ← TRUE ENDIF ENDWHILE | FIndex ← Index + 1 is missing inside the loop, so Index never changes and the loop repeats the same item forever when the target is not at position 1. |
Complete each line of code by filling in the missing parts.
Shade in the letter of the line that contains an error.
WHILE Found = FALSE AND Index <= 10 DO — Keeps searching while the target has not been found AND the end of the list has not been reached, so the loop stops early as soon as Found becomes TRUE.WHILE Found = FALSE AND Index <= 10 DOWHILE Found = FALSE AND Index <= 10 DO
Index ← Index + 1
ENDWHILE IF List[Index] = Target THEN
Found ← TRUE
Position ← IndexUNTIL Found = TRUE OR Index > 10Found ← FALSE
Index ← 1
WHILE Found = FALSE AND Index <= 10 DO