Cambridge O Level Computer Science 2210 · 7.7 Trace tables

Q45 · 2210/21/M/J/20 Q5

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

Q452210/21/M/J/20original Q5Structured · 6 marks
Question 5 from 2210/21/M/J/20

Worked solution

(a)

Run the flowchart once for each input. Calc1 and Calc2 use DIV, so they drop any remainder. A value is output only when Calc1 = Value / 2 and Calc2 = Value / 3, which means Value divides exactly by 2 and by 3. Input -1 ends the algorithm.

ValueCalc1Calc2OUTPUT
502516
331611
189618
1575
30151030
-1

Value column correct [1]

Calc1 column correct [1]

Calc2 column correct [1]

OUTPUT column correct [1]

(b)

The algorithm outputs each input value [1]

that is divisible by 6 (divisible by both 2 and 3). [1]

KEY IDEAComparing a DIV result with the exact division tells you if the number divides with no remainder.
TOTAL 6 marks

Official mark scheme

Mark scheme for 2210/21/M/J/20 question 5
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.