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 Number <> -1 DO | AINPUT Word WHILE Word <> "STOP" DO Count <- Count + 1 INPUT Word ENDWHILE | |
| 2INPUT Number WHILE Number <> -1 DO | BINPUT is at the start of the body, so the rogue value -1 is added to the total before the loop condition is checked. It should be read at the end of the body. | |
| 3Read the next value at the end of the loop body so the rogue value can be checked on the next test | CKeeps looping until the user types the rogue value -1, which signals the end of the input and is not real data | |
| 4A text rogue value such as STOP ends the loop and is never added to the total or counted | DThere is no INPUT before the loop or inside it, so Number never changes and the loop never ends (or Number has no value to test). | |
| 5WHILE Number <> -1 DO INPUT Number Total <- Total + Number ENDWHILE | EThe first value is read before the loop so the WHILE condition has something to test, even if it is the rogue value straight away | |
| 6WHILE Number <> -1 DO Total <- Total + Number ENDWHILE | FWHILE Number <> -1 DO Total <- Total + Number INPUT Number ENDWHILE |
Complete each line of code by filling in the missing parts.
Shade in the letter of the line that contains an error.
WHILE Number <> -1 DO — Loop that repeats until the user types a rogue (sentinel) value such as -1. INPUT before the loop and again at the end of the body; the rogue value is not counted or totalled.INPUT Number
WHILE Number <> -1 DO
Total <- Total + NumberINPUT Number
WHILE Number <> -1 DO
Total <- Total + Number Total <- Total + Number
INPUT Number
ENDWHILEINPUT Number
WHILE Number <> -1 DO
Count <- Count + 1WHILE Number <> -1 DO
Count <- Count + 1
INPUT Number