The question below uses a robot in a grid of squares. The robot is represented as a triangle, which starts in the bottom left square of the grid facing up. The robot can move into any white square (including the numbered squares) but not into a black square.
The program below is intended to move the robot from its starting position on the left to the far right of the grid. It uses the procedure Square_Number () which returns the value of the number written on the square if there is one and returns 0 otherwise.
REPEAT UNTIL NOT (Square_Number ()=0)
{
IF (CAN_MOVE (right))
{
ROTATE_RIGHT ()
}
IF (CAN_MOVE (forward))
{
MOVE_FORWARD ()
}
IF (CAN_MOVE (left))
{
ROTATE_LEFT ()
}
}
What is the result of running the program?



Answer :

Other Questions