2210/22/O/N/22 question 5: worked solution (October/November 2022, paper 22)

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. Q69 2210/22/O/N/22 original Q5 Structured · 8 marks Worked solution (a) Four errors, each with its correction. Write any four of these: Error: line 09 stores MarksEntry. Correction: Higher[HighList] ← Mark [1] Error: line 15 does not change MidList. Correction: MidList ← MidList + 1 [1] Error: line 17 uses the wrong counter. Correction: Lower[LowList] ← Mark [1] Error: line 22 uses NEXT with a condition. Correction: UNTIL MarksEntry = 500 [1] (b) Ask the user after each mark whether to carry on, and stop when they say no. Write this at the end of the loop, replacing line 22: OUTPUT "Do you want to enter another mark?" INPUT AnotherMark UNTIL AnotherMark = "No" A question is output and an answer is input to decide whether to end [1] These statements are placed at the end of the loop, after the marks are stored [1] The test UNTIL AnotherMark = "No" replaces line 22 [1] Remove the MarksEntry counter, lines 04 and 21, as it is no longer needed [1] Other correct ways score, for example a WHILE loop with AnotherMark = "Yes", or ending when Mark = -1. KEY IDEA Read the pseudocode line by line and check each assignment, counter and loop ending. TOTAL 8 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.