2210/21/M/J/20 question 5: worked solution (May/June 2020, paper 21)
Show as plain textHide plain text
Cambridge O Level Computer Science 2210 · 7.7 Trace tables Worked solution from the Algorithm design and problem-solving Paper 2 Algorithms, Programming and Logic booklet, Part 6 of 8. Q45 2210/21/M/J/20 original Q5 Structured · 6 marks 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. Value Calc1 Calc2 OUTPUT 50 25 16 33 16 11 18 9 6 18 15 7 5 30 15 10 30 -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 IDEA Comparing a DIV result with the exact division tells you if the number divides with no remainder. TOTAL 6 marks Official mark scheme VIDEO ▶ Topic lesson A lesson on this topic · by Mr Bulmer's Learning Zone. Tap the picture to open it on YouTube.