Cambridge O Level Computer Science 2210 · 7.9 Writing and amending algorithms

Q84 · 2210/22/O/N/20 Q4

Worked solution from the Algorithm design and problem-solving Paper 2 Algorithms, Programming and Logic booklet, Part 8 of 8.

Q842210/22/O/N/20original Q4Structured · 6 marks
Question 4 from 2210/22/O/N/20

Worked solution

Set Higher to 0 before the loop, test each number as it is input, and output Higher once after the loop.

Higher ← 0
FOR Count ← 1 TO 5000
    INPUT Number[Count]
    IF Number[Count] > 500
      THEN
        Higher ← Higher + 1
    ENDIF
NEXT Count
OUTPUT "There are ", Higher, " values that are greater than 500"

Higher set to 0 before the loop [1]

An IF statement used [1]

Correct condition in the IF (Number[Count] > 500) [1]

Correct counting statement inside the loop [1]

OUTPUT with a correct reference to Higher, after the loop [1]

An appropriate message in the output [1]

KEY IDEAInitialise a counter before the loop, add to it inside the loop when the test is true, and output it after the loop.
TOTAL 6 marks

Official mark scheme

Mark scheme for 2210/22/O/N/20 question 4
VIDEO
▶ Whole paper

Video solution of the whole paper · by Quixotic Academy. 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.