Question 2 2019 · October-November · Paper 22 · 4 marks
Reveal official mark-scheme answer
Official answer for Question 2
Question 4
- 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
Show text version of question
Question 2
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 .........................................................................................................................................
..........................................................................................................................................................
Question 8
Why this question appears here
98% assigned-topic match · Programming › Programming concepts
Topic-match percentages estimate how closely each question fits the selected syllabus topic. They are a guide for choosing stricter or broader practice.
Permanent source page: Educate A Change · From 2210_w19_qp_22.pdf
