Cambridge O Level Computer Science 2210 · 8.1 Programming concepts

Q7 · 2210/23/O/N/20 Q2

Worked solution from the Programming Paper 2 Algorithms, Programming and Logic booklet, Part 1 of 3.

Q72210/23/O/N/20original Q2Structured · 12 marks
Question 2 from 2210/23/O/N/20

Worked solution

(a)

Look for each type of statement in the numbered lines.

Assignment statement: line 01 (or 02, 08 or 12) [1]

Loop: line 03 and/or line 14 (REPEAT … UNTIL) [1]

Counting statement: line 08 or 12 [1]

Selection statement: line 06 (or 10, 15 or 19) [1]

(b)

Read what each part of the algorithm should do.

Line 02: TooCold starts at 1000. Change to TooCold ← 0 [1]

Line 08: the count goes down. Change to TooCold ← TooCold + 1 [1]

Line 15: it should be more than 5. Change to IF TooHot > 5 [1]

Line 17: INPUT is used to show a message. Change to OUTPUT "Alarm!!" [1]

(c)

Count the readings that are inside the range with a new counter. Any four of these:

Add a new variable, for example InRange [1]

Set it to 0 at the start of the algorithm [1]

Add an extra IF statement with the test Temperature >= -25 AND Temperature <= -18 [1]

If it is true, add 1 to InRange [1]

KEY IDEACounters start at the right value and move the right way, and INPUT reads data while OUTPUT shows it.
TOTAL 12 marks

Official mark scheme

Mark scheme for 2210/23/O/N/20 question 2
VIDEO
▶ 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.