2210/22/M/J/25 question 7: worked solution (May/June 2025, paper 22)

Show as plain text

Cambridge O Level Computer Science 2210 · 7.9 Writing and amending algorithms Worked solution from the Algorithm design and problem-solving Paper 2 Algorithms, Programming and Logic booklet, Part 8 of 8. Q112 2210/22/M/J/25 original Q7 Structured · 10 marks Worked solution (a) Fill in each empty box using what the question says. The algorithm inputs a value, rejects it if it is out of range (and inputs again), otherwise adds it to the total and counts it. It stops when 50 values are accepted. Top parallelogram: INPUT Value [1] First decision (Yes goes back to the input, No continues left): IS Value <= -20 OR Value >= 50 ? [1] Left process box (No branch): Total ← Total + Value [1] Second process box: Count ← Count + 1 [1] Second decision (Yes continues down, No goes back to the input): IS Count = 50 ? [1] The two output parallelograms: OUTPUT Total and then OUTPUT Total / 50 [1] (b) To keep every value, use an array and a second loop: Change INPUT Value so that each accepted value is saved into an array , for example Numbers[Count] ← Value [1] ... using the counter as the index [1] After the first loop (outside it), add a second loop that repeats 50 times [1] Inside the second loop add an OUTPUT that outputs the array content at the counter position, for example OUTPUT Numbers[Count] [1] KEY IDEA Totalling and counting go inside the loop, the averaging goes after it, and an array lets you keep every value to output later. TOTAL 10 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.