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

Show as plain text

Cambridge O Level Computer Science 2210 · 7.8 Identifying and correcting errors in algorithms Worked solution from the Algorithm design and problem-solving Paper 2 Algorithms, Programming and Logic booklet, Part 7 of 8. Q76 2210/21/M/J/25 original Q6 Structured · 6 marks Worked solution (a) Read the code line by line and compare it with what the algorithm should do. Write four of these: Line 02: ROUND(..., 1) gives a decimal. Correction: N ← ROUND(RANDOM() * 99, 0) + 1 [1] Line 12: the message says lower again. Correction: OUTPUT "The number is higher than your guess" [1] Line 14: Counter is inside the ELSE part, so it is only added to when the guess is not too high (and is missed when the guess is too high). Correction: move Counter ← Counter + 1 to after ENDIF (line 15), before UNTIL G = N [1] Line 17: Guess is never used. Correction: OUTPUT "Well done, you took ", Counter, " attempts" [1] (b) Give a method and an example of it: Method: use meaningful identifier names [1] Example: rename N to Number (or G to Guess). [1] Other methods that score: comments (for example // loops until the guess equals the number) or writing the algorithm as a procedure or function . KEY IDEA Compare each line with the stated purpose: wrong values, repeated messages, misplaced statements and unused variables are the usual errors. 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.