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 <> 0 DO | AStart of a pre-condition loop: the condition is tested before each repeat, and the loop keeps going while Number is not 0 | |
| 2ENDWHILE | BCount never changes inside the body, so the condition stays TRUE forever and the loop never ends | |
| 3If the condition is FALSE the first time it is tested, the loop body never runs (zero times) | CCloses the WHILE loop; the statements between WHILE and ENDWHILE are the body that repeats | |
| 4The body must change a variable used in the condition so the loop can end | DNumber <- 0 WHILE Number <> 0 DO OUTPUT Number ENDWHILE | |
| 5WHILE Number <> 0 DO OUTPUT Number INPUT Number END | EThe loop is closed with END instead of ENDWHILE, so the pseudocode is not valid | |
| 6Count <- 1 WHILE Count <= 5 DO OUTPUT Count ENDWHILE | FWHILE Number <> 0 DO 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 <> 0 DO — A pre-condition loop: the condition is tested before every repeat, so the body may run zero times. The loop keeps going while the condition is TRUE and is closed by ENDWHILE.WHILE Number <> 0 DO
INPUT Number
ENDWHILEWHILE Number <> 0 DO
INPUT Number
ENDWHILEWHILE Number <> 0 DO
INPUT Number
ENDWHILEWHILE Number <> 0 DO
INPUT Number
ENDWHILEWHILE Count < 5 DO
Count <- Count + 1
ENDWHILE