Computer Science · May / June 2024 · Paper 22 · Question 11
2210
As printed in the paper
The question as text
A one-player game uses the two-dimensional (2D) array Grid[] to store the location of a secret cell to be found by the player in 10 moves. Each row and column has 5 cells. Start Grid[1,1] At the start of the game: • The program places an ‘X’ in a random cell (not in Grid[1,1]) and empties all the other cells in the grid. • The player starts at the top left of the grid. • The player has 10 moves. During the game: • The player can move left, right, up or down by one cell and the move must be within the grid. • “You Win” is displayed if the player moves to the cell with ‘X’ and has played 10 moves or less. • “You Lose” is displayed if the player has made 10 moves without finding the ‘X’. Write a program that meets these requirements. You must use pseudocode or program code and add comments to explain how your code works. You do not need to declare any arrays or variables; you may assume that this has already been done. All inputs and outputs must contain suitable messages.
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.

