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 >= 1 AND Age <= 100 | AThe error message. In the trace table it is written in the OUTPUT column on the row of each rejected value, and not on the row of the accepted value. | |
| 2OUTPUT "Invalid age" | BThe rejected value -4 was left out of the trace. Every attempt must be recorded, so there should be two error messages, one for 150 and one for -4, before 35 is accepted. | |
| 3Tracing a validation loop with the inputs 150, -4, 35 for a range check 1 to 100 gives two rejected values and 35 as the value finally accepted. | CWHILE Age < 1 OR Age > 100 DO OUTPUT "Invalid age" INPUT Age ENDWHILE | |
| 4In a trace table the Age column lists every attempt in order, so a row is added for each INPUT the loop asks for until a valid value is entered. | DINPUT Age WHILE Age < 1 OR Age > 100 DO INPUT Age ENDWHILE | |
| 5Trace of inputs 150, -4, 35 (range 1 to 100): the Age column shows 150, 35 and the output column shows one error message. | EA validation loop: it keeps asking for Age until the value is inside the range 1 to 100, so each rejected attempt gets its own row in the trace. | |
| 6Trace of inputs 150, -4, 35 (range 1 to 100): the output column shows an error message on the row where Age is 35. | F35 is valid normal data, so no error message is output for it. The messages belong on the rows for 150 and -4 only, and 35 is the accepted value that ends the loop. |
Complete each line of code by filling in the missing parts.
Shade in the letter of the line that contains an error.
Tracing a validation loop — Step through a validation loop with valid and invalid inputs, recording each rejected value, the error message output and the value finally accepted in a trace table.REPEAT
INPUT Age
UNTIL Age >= 1 AND Age <= 100WHILE Age < 1 OR Age > 100 DO
OUTPUT "Invalid age"
INPUT AgeINPUT Age
WHILE Age < 1 OR Age > 100 DO
OUTPUT "Invalid age"REPEAT
INPUT Mark
UNTIL Mark >= 0 AND Mark <= 50REPEAT
INPUT Score
UNTIL Score >= 0 AND Score <= 100