Question 9

AQA Computer Science Specimen Paper 1A (8525/1A)GCSE6 marks

On the specification

9.1
3.2 Programming
9.2
3.2 Programming
Question text

9 Four separate subroutines have been written to control a robot. • Forward(n) moves the robot n squares forward. • TurnLeft() turns the robot 90 degrees left. • TurnRight() turns the robot 90 degrees right. • ObjectAhead() returns true if the robot is facing an object in the next square or returns false if this square is empty. 9.1 Draw the path of the robot through the grid below if the following program is executed (the robot starts in the square marked by the ↑ facing in the direction of the arrow). Forward(2) TurnLeft() Forward(1) TurnRight() Forward(1) [3 marks] ↑ 9.2 Draw the path of the robot through the grid below if the following program is executed (the robot starts in the square marked by the ↑ facing in the direction of the arrow). If a square is black then it contains an object. WHILE ObjectAhead() = true TurnLeft() IF ObjectAhead() = true THEN TurnRight() TurnRight() ENDIF Forward(1) ENDWHILE Forward(1) [3 marks] ↑