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 | AKeeps asking for Age until it is in the range 0 to 120, so an invalid age never gets into the algorithm. | |
| 2REPEAT INPUT Name UNTIL LENGTH(Name) > 0 | BKeeps asking for Name until something is typed in, which is a presence check. | |
| 3A validation loop that shows an error message each time the value is outside the range 1 to 10 | CINPUT Mark WHILE Mark < 0 OR Mark > 100 DO INPUT Mark ENDWHILE | |
| 4The WHILE form of a range check: read first, then keep asking while the value is invalid | DOR makes the condition true for every number, so the range check never rejects anything. It should use AND. | |
| 5REPEAT INPUT Mark UNTIL Mark < 0 OR Mark > 100 | EREPEAT INPUT Score IF Score < 1 OR Score > 10 THEN OUTPUT "Enter 1 to 10" ENDIF UNTIL Score >= 1 AND Score <= 10 | |
| 6REPEAT INPUT Mark UNTIL Mark >= 0 OR Mark <= 100 | FThe UNTIL condition tests for invalid values, so the loop stops as soon as the mark is wrong. It should be UNTIL Mark >= 0 AND Mark <= 100. |
Complete each line of code by filling in the missing parts.
Shade in the letter of the line that contains an error.
REPEAT INPUT Mark UNTIL Mark >= 0 AND Mark <= 100 — A validation loop: it asks for INPUT again and again until the value passes the check (here a range check), so invalid data never enters the algorithm.REPEAT
INPUT Mark
UNTIL Mark >= 0 AND Mark <= 100REPEAT
INPUT Password
UNTIL LENGTH(Password) >= 8IF Mark < 0 OR Mark > 100 THEN
OUTPUT "Invalid mark"
ENDIFWHILE Mark < 0 OR Mark > 100 DO
INPUT Mark
ENDWHILEREPEAT
INPUT Mark
UNTIL Mark >= 0 AND Mark <= 100