Worked solution from the Algorithm design and problem-solving Paper 2 Algorithms, Programming and Logic booklet, Part 7 of 8.
Check each line:
Line 01: Loop is a counter, so DECLARE Loop : INTEGER [1]
Line 07: IF used instead of a loop, so write FOR Loop ← 1 TO Limit [1]
Line 09: the number must go into Value, so INPUT Value [1]
Line 10: values should be added, so Total ← Total + Value [1]
Use ROUND with the value and the number of decimal places:
OUTPUT "The average of the numbers entered is ", ROUND(Total / Limit, 1)
ROUND used with two values separated by a comma [1]
Correct values: Total / Limit and 1 [1]
Check the value straight after it is input, and ask again if it is wrong:
After line 09 (the input), add a WHILE loop (pre-condition loop) [1]
It checks that the value is between 1 and 500 inclusive [1]
If the value is outside the range, output an error message [1]
and input the value again inside the loop [1]
A REPEAT loop also scores: start it before the input message and end it with UNTIL the value is from 1 to 500.
▶ Whole paper
Video solution of the whole paper · by ZAINEMATICS. Tap the picture to open it on YouTube.
Solutions follow the official Cambridge mark schemes; marks are shown in grey. Videos are from other YouTube channels. Paper codes read component / series / year: M/J = May/June, O/N = October/November. Past-paper questions © UCLES, reproduced for classroom practice.