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 | |
|---|---|---|
| 1IF Age < 0 OR Age > 120 THEN | AThe input is used straight away with no validation, so a negative or silly quantity gives a wrong total | |
| 2OUTPUT "Invalid input, try again" | BAverage ← (Mark1 + Mark2) / 2 // Mark2 typed as 800 | |
| 3Validation keeps asking until the data passes the check, so bad data is never used | CREPEAT INPUT Mark UNTIL Mark >= 0 AND Mark <= 100 | |
| 4Without validation, bad data gives wrong results, such as an average calculated from an impossible mark | DThe error message is shown but the user is not asked again, so the invalid data is still used | |
| 5INPUT Quantity Total ← Price * Quantity // Quantity is used without any check | EA validation check that rejects an unreasonable age before it is used | |
| 6IF Age < 0 THEN OUTPUT "Error" ENDIF // the program then carries on | FThe error message shown when data fails validation, before the user is asked again |
Complete each line of code by filling in the missing parts.
Shade in the letter of the line that contains an error.
validation — An automatic check by the program that input data is reasonable and in the right form. Bad data is rejected with an error message and the user is asked again, so it is never used.IF Age < 0 OR Age > 120 THEN
OUTPUT "Invalid age"
ENDIFREPEAT
INPUT Mark
UNTIL Mark >= 0 AND Mark <= 100IF Age > 120 THEN
OUTPUT "Age is too high"
ENDIFWHILE Score > 100 DO
INPUT Score
ENDWHILEIF LENGTH(Password) < 8 THEN
OUTPUT "Password too short"
ENDIF