An algorithm has been written in pseudocode to generate a random integer between 1 and 100 inclusive and store the value in N. The user enters a guess for the number and the algorithm indicates whether the guess is higher or lower than the random number. The algorithm outputs the number of guesses when the user has correctly guessed the random number. 01 Counter ← 0 02 N ← ROUND(RANDOM() * 99, 1) + 1 03 REPEAT 04 OUTPUT "Please enter a guess" 05 INPUT G 06 IF G > N 07 THEN 08 OUTPUT "The number is lower than your guess" 09 ELSE 10 IF G < N 11 THEN 12 OUTPUT "The number is lower than your guess" 13 ENDIF 14 Counter ← Counter + 1 15 ENDIF 16 UNTIL G = N 17 OUTPUT "Well done, you took ", Guess, " attempts"
- (a)Identify the line numbers of the four errors in the pseudocode and suggest a correction for each error. Error 1 line number Correction Error 2 line number Correction Error 3 line number Correction Error 4 line number Correction[4]
- (b)Identify one method to make the algorithm maintainable. Give an example.[2]
Mark scheme
Marking points from the official mark scheme (May/June 2025). The mark or mark type is shown in brackets.
- [1] (a) Error 1 line number: 02 - Correction: N ← ROUND(RANDOM() * 99, 0) + 1
- [1] (a) Error 2 line number: 12 - Correction: OUTPUT "The number is higher than your guess"
- [1] (a) Error 3 line number: 14/15 - Correction: Counter ← Counter + 1 should be placed after Line 15/After ENDIF/before UNTIL G = N/before Line 16
- [1] (a) Error 4 line number: 17 - Correction: OUTPUT "Well done, you took ", Counter, " attempts"
- [1] (b) Meaningful identifiers
- [1] (b) Example: N should be Number
- [1] (b) Comments
- [1] (b) Example: // loops until the guess equals the number
- [1] (b) Procedures/functions
- [1] (b) Example: Making the algorithm a procedure/function
Write your answer and get it marked
On Oracle Prep you can write or photograph your own answer and have it marked by AI against this mark scheme, with feedback on what you missed.
Sign up free →