Computer Science · May / June 2025 · Paper 21 · Question 6
0478
As printed in the paper
The question as text
An algorithm has been written in pseudocode to generate a random integer between 1 and 100 inclusive and store the value in . 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. £ ¤¥¦¤§¥¨ © ªª« ¨ ¬ ¦ ® ¯ ° ± ² ± ³ ´ µ ¶ · ¸ ¹ º · » ¯ ª ¼½ ± ¾ µ £ · ¸ ¹ º · » ¯ ¤ ® ¬ ° ¤ ² ¼ ± ¿ ´ À Á « »  « ± « Ã
Read automatically from the paper; the printed page above is exact.
Show the answer and mark scheme
6(a)[4]
One mark for each line identified and corrected.
Line 02 – should be N ← ROUND(RANDOM() * 99, 0) + 1
Line 14/15 - Counter ← Counter + 1 should be placed after Line 15/After ENDIF/before UNTIL G = N/before Line Line 12 – should be OUTPUT "The number is higher than your guess"
16
Line 17 – should be OUTPUT "Well done, you took ", Counter, " attempts"
6(b)[2]
One mark for method, one mark for example – max 2.
Meaningful identifiers, N should be Number.Comments, // loops until the guess equals the numberProcedures/functions, making the algorithm a procedure/function
Make a free account to save your answers and see your weak topics and ask the AI why a wrong answer is wrong.

