Cambridge AS Level Computer Science 9618 · 9.2 Algorithms

Q45 · 9618/22/O/N/25 Q2

Worked solution from the Algorithm Design and Problem-solving Paper 2 Problem-solving and Programming booklet, Part 2 of 2.

Q459618/22/O/N/25original Q2Structured · 5 marks
Question 2 from 9618/22/O/N/25

Worked solution

Draw a loop that inputs a value, stops on 99.9 or when the array is full:

START → Set Index to 1 → Input Num → decision "Is Num = 99.9?"

If YES: END. If NO: Set Data[Index] to Num → Set Index to Index + 1 → decision "Is Index = 21?" If YES: END. If NO: back to Input Num.

Array index set to 1 before the loop [1]

Input a number inside the loop [1]

Test for 99.9 with correct ending, before it is stored [1]

Test for the array full (Index = 21, or 20 repeats) with correct ending [1]

Assign the number to Data[Index] and increase the index [1]

One decision "Num = 99.9 or Index = 21" placed straight after the input is also accepted.

KEY IDEACheck for the end value straight after input so 99.9 is never stored, and stop after the 20th element.
TOTAL 5 marks

Official mark scheme

Mark scheme for 9618/22/O/N/25 question 2
VIDEO
▶ Whole paper

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