Computer Science · Oct / Nov 2019 · Paper 22 · Question 2
2210
As printed in the paper
The question as text
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. Error 1 Correction Error 2 Correction Error 3 Correction Error 4 Correction [4]
Read automatically from the paper; the printed page above is exact.
Show the answer and mark scheme
Make a free account to save your answers and see your weak topics and ask the AI why a wrong answer is wrong.

