Cambridge AS Level Computer Science 9618 · 9.2 Algorithms

Q30 · 9618/21/O/N/23 Q2

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

Q309618/21/O/N/23original Q2Structured · 7 marks
Question 2 from 9618/21/O/N/23

Worked solution

(a)

Write five short steps in plain words, in the right order. Do not use pseudocode.

Step 1: set the total to zero [1]

Step 2: input a number [1]

Step 3: check whether the number is between 30 and 70 inclusive (greater than 29 and less than 71) [1]

Step 4: if it is, add the number to the total [1]

Step 5: repeat steps 2 to 4 until 100 numbers have been input, then output the total [1]

Another way to score: give the repeat step and the output step as two separate steps (any five of the points earn the marks).

(b)

Name the two constructs besides sequence.

Iteration (a count-controlled loop) [1]

Selection (an IF statement) [1]

KEY IDEABreak the problem into small ordered steps: set up, input, test, add, repeat, then output.
TOTAL 7 marks

Official mark scheme

Mark scheme for 9618/21/O/N/23 question 2
VIDEO
▶ Starts at Q2 (9:40)

Starts at Q2 (9:40) · by Pseudocode Pro. 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.