An algorithm has been written in pseudocode to select a random number using the function RandInt(n), which returns a whole number between 1 and the argument n. The algorithm then allows the user to guess the number. Number ← RandInt(100) TotalTry ← 1 REPEAT PRINT "Enter your guess now, it must be a whole number" INPUT Guess IF TotalTry > Number THEN PRINT "Too large try again" ENDIF IF Guess > Number THEN PRINT "Too small try again" ENDIF TotalTry ← Guess + 1 UNTIL Guess <> Number TotalTry ← TotalTry - 1 PRINT "Number of guesses ", TotalTry Find the four errors in the pseudocode and suggest a correction to remove each error.
- (a)Find the four errors in the pseudocode and suggest a correction to remove each error.[4]
Mark scheme
Marking points from the official mark scheme (Oct/Nov 2019). The mark or mark type is shown in brackets.
- [4] One mark for each error identified and suggested correction:
- ∞ IF TotalTry > Number should be IF Guess > Number
- ∞ IF Guess > Number should be IF Guess < Number
- ∞ TotalTry ← Guess + 1 should be TotalTry ← TotalTry + 1
- ∞ UNTIL Guess <> Number should be UNTIL Guess = Number
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 →