2210/23/O/N/24 question 6: worked solution (October/November 2024, paper 23)

Show as plain text

Cambridge O Level Computer Science 2210 · 8.2 Arrays Worked solution from the Programming Paper 2 Algorithms, Programming and Logic booklet, Part 2 of 3. Q57 2210/23/O/N/24 original Q6 Structured · 9 marks Worked solution (a) The loop counts values until A[C] is 0, so C must start at 1, W is the running total, and X is the average. Line 06: C ← 1 [1] Line 08: W ← W + A[C] [1] Line 11: X ← W / (C - 1) (ROUND(W / (C - 1), 0) is also accepted) [1] (b) The number of values is C - 1, because C ends one past the last value. OUTPUT "Number of values stored in the array: ", C - 1 OUTPUT "Average of the values stored: ", X Output of the number of values (C - 1) [1] Output of the average X [1] Suitable messages with both outputs [1] (c) Write a name that says what each item holds. Array A: Values (or similar) [1] Variables, any suitable names, for example C: Index , X: Average , W: Total . Three suitable names score 2 marks, one or two score 1 mark. [2] KEY IDEA Counter starts at 1, total adds each value, and the count of values is one less than the final counter. TOTAL 9 marks Official mark scheme VIDEO ▶ Topic lesson A lesson on this topic · by Craig'n'Dave. Tap the picture to open it on YouTube.