Note AcademyNote Academy

Computer Science · May / June 2025 · Paper 21 · Question 6

2210

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 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"

Read automatically from the paper; the printed page above is exact.

Show the answer and mark scheme
  • 6(a)[4]

  • 6(b)[2]

Make a free account to save your answers and see your weak topics and ask the AI why a wrong answer is wrong.