Cambridge O Level Computer Science 2210 · 7.8 Identifying and correcting errors in algorithms

Q80 · 2210/23/O/N/25 Q7

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

Q802210/23/O/N/25original Q7Structured · 8 marks
Question 7 from 2210/23/O/N/25

Worked solution

(a)

Write three of these errors with their corrections:

Error 1: line 02. Change to DECLARE DenaryNumber : INTEGER (CHAR cannot be used with MOD and DIV) [1]

Error 2: line 05. Change to FOR Count ← 8 TO 1 STEP -1 (8 bits are needed) [1]

Error 3: line 06. Change to BinaryArray[Count] ← MOD(DenaryNumber, 2) (binary uses base 2) [1]

(b)

Write any one of: iteration (the FOR loop), input, output. [1]

(c)(i)

Write: range check [1]

(c)(ii)

Repeat the input until the number is between 1 and 255.

REPEAT
    INPUT DenaryNumber
UNTIL DenaryNumber >= 1 AND DenaryNumber <= 255

A suitable loop [1]

A suitable condition checking both limits [1]

DenaryNumber input inside the loop [1]

KEY IDEAA range check keeps asking for input until the value lies between the lower and upper limit.
TOTAL 8 marks

Official mark scheme

Mark scheme for 2210/23/O/N/25 question 7
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.