The following program moves a robot in a grid of squares. The initial position and direction of the robot is shown below. Click on the grid to move the robot to the final position after the program is run. You must click within the box to rotate the robot to the correct final direction (click near the top of the box to rotate up, etc...) Feel free to move the robot along as you follow the code.
The following
PROCEDURE DoSomething(a)
{
MOVE_FORWARD()
if( a > 2 )
{
MOVE_FORWARD()
}
else
{
if( a = 3 )
{
MOVE_FORWARD()
}
}
MOVE_FORWARD()
}
i ⬅ 3
ROTATE_RIGHT()
REPEAT 2 TIMES
{
DoSomething(i)
MOVE_FORWARD()
ROTATE_RIGHT()
i ⬅ i - 1
}
![1
2
3
4
5
67
F F 500
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
PROCEDURE DoSomething (a)
{
}
MOVE_FORWARD ()
if( a > 2 )
{
}
MOVE_FORWARD ()
}
else
{
if( a = 3 )
{
MOVE_FORWARD ()
MOVE_FORWARD ()
1 - 3
ROTATE_RIGHT()
REPEAT 2 TIMES
{
DoSomething (i)
MOVE_FORWARD()
ROTATE_RIGHT()
i-i-1](/v2/_next/image?url=https%3A%2F%2Fcontent.bartleby.com%2Fqna-images%2Fquestion%2Fc5fbb734-1ef4-4c4b-ac98-7009bc3f1d6e%2F3021e5b6-b2a6-4bc8-9123-e40708692136%2F72hj2w_processed.jpeg&w=3840&q=75)
![](/static/compass_v2/shared-icons/check-mark.png)
Trending now
This is a popular solution!
Step by step
Solved in 2 steps
![Blurred answer](/static/compass_v2/solution-images/blurred-answer.jpg)
![Database System Concepts](https://www.bartleby.com/isbn_cover_images/9780078022159/9780078022159_smallCoverImage.jpg)
![Starting Out with Python (4th Edition)](https://www.bartleby.com/isbn_cover_images/9780134444321/9780134444321_smallCoverImage.gif)
![Digital Fundamentals (11th Edition)](https://www.bartleby.com/isbn_cover_images/9780132737968/9780132737968_smallCoverImage.gif)
![Database System Concepts](https://www.bartleby.com/isbn_cover_images/9780078022159/9780078022159_smallCoverImage.jpg)
![Starting Out with Python (4th Edition)](https://www.bartleby.com/isbn_cover_images/9780134444321/9780134444321_smallCoverImage.gif)
![Digital Fundamentals (11th Edition)](https://www.bartleby.com/isbn_cover_images/9780132737968/9780132737968_smallCoverImage.gif)
![C How to Program (8th Edition)](https://www.bartleby.com/isbn_cover_images/9780133976892/9780133976892_smallCoverImage.gif)
![Database Systems: Design, Implementation, & Manag…](https://www.bartleby.com/isbn_cover_images/9781337627900/9781337627900_smallCoverImage.gif)
![Programmable Logic Controllers](https://www.bartleby.com/isbn_cover_images/9780073373843/9780073373843_smallCoverImage.gif)