Worked solution from the Algorithm design and problem-solving Paper 2 Algorithms, Programming and Logic booklet, Part 8 of 8.
Count starts at 0 and goes up by 1 each time round the loop. [1]
The test is made after it has gone up, so Count can never be 0 at the end of the loop. The condition UNTIL Count = 0 is never true, so the loop never ends. [1]
Use a separate variable for the input, store it only if it is 100 or more, and stop after 50 numbers.
Count ← 0
REPEAT
INPUT Number
IF Number >= 100
THEN
Values[Count] ← Number
ENDIF
Count ← Count + 1
UNTIL Count = 50A separate INPUT statement for the number (not into the array) [1]
An IF statement is attempted [1]
The IF statement is completely correct (Number >= 100 and the store inside it) [1]
The loop ending changed to UNTIL Count = 50 [1]
Change the IF statement (or add a second IF) so the number is also tested to be less than or equal to 200 [1]
The number is then stored only when both tests are true, for example Number >= 100 AND Number <= 200. [1]
▶ Topic lesson
A lesson on this topic · by Mr Bulmer's Learning Zone. 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.