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 | |
|---|---|---|
| 1REPEAT INPUT Age UNTIL Age >= 0 AND Age <= 120 | AREPEAT OUTPUT "Enter 1 to 10" INPUT Num UNTIL Num >= 1 AND Num <= 10 | |
| 2IF Age < 0 OR Age > 120 THEN OUTPUT "Invalid age" ENDIF | BINPUT Mark WHILE Mark < 0 OR Mark > 100 DO INPUT Mark ENDWHILE | |
| 3A WHILE version asks for the first input before the loop, then repeats the INPUT while the value is invalid | CThere is no INPUT before the WHILE loop, so Num has no value to check the first time. Add INPUT Num before the loop. | |
| 4A REPEAT loop always runs the prompt and INPUT at least once, and UNTIL checks the value is valid | DThe UNTIL condition describes invalid data, so the loop stops on an invalid age and keeps asking for valid ones. It should be UNTIL Age >= 0 AND Age <= 120. | |
| 5REPEAT INPUT Age UNTIL Age < 0 OR Age > 120 | EKeeps asking for Age until the value is inside the valid range 0 to 120, then the loop ends | |
| 6WHILE Num < 1 OR Num > 10 DO INPUT Num ENDWHILE | FShows an error message inside the loop when the value fails the validation check |
Complete each line of code by filling in the missing parts.
Shade in the letter of the line that contains an error.
REPEAT INPUT UNTIL valid — A REPEAT loop around INPUT that keeps asking for a value and shows an error message each time the check fails. The UNTIL condition is the valid range, so the loop ends only on valid data.REPEAT
INPUT Age
UNTIL Age >= 1 AND Age <= 100REPEAT
INPUT Mark
UNTIL Mark >= 0 AND Mark <= 100REPEAT
INPUT Mark
UNTIL Mark >= 0 AND Mark <= 100WHILE Mark < 0 OR Mark > 100 DO
INPUT Mark
ENDWHILEIF Mark < 0 OR Mark > 100 THEN
OUTPUT "Invalid mark"
ENDIF