With your basebot configured with a pen as in lab #1, write a C program that wil
ID: 3576510 • Letter: W
Question
With your basebot configured with a pen as in lab #1, write a C program that will draw a single equilateral triangle with side lengths of 24 inches. Fortunately, your lab partner remembered that you had written the following functions for a previous lab and so you are free to use them in this program. Forward(distance); // drive the robot forward distance inches Reverse(distance); // drive the robot backward distance inches Wait(ms); // have the program wait for ms milliseconds Right(angle); // have the robot turn right angle degrees Left(angle); //have the robot turn left angle degrees Halt(); // have the robot come to a complete Two hints showing some C syntax:Explanation / Answer
// suppose all the function as you have mentioned is given
// like Forward(distance), reverse(distance), right(angle), left(angle), wait(ms), halt()
#include <stdio.h>
void printEquilateralTriangle(){
int side = 24; // 24 inches side length
// first move the robot to top of the triangle position
forward(side/2); // its around 12 inches
right(90); // rotate the robot to right 90 degree angle
right(30); // rotate the robot to 30 degree angle
//now draw the left side of triangle
draw(); // draw traces in robot path now
forward(side); // in left side of trinagle
left(60); // turn robot left by 60 degree
// now draw the base of triangle
draw(); // draw traces in robot path now
forward(side); // base of triangle
left(60); // turn 60 degree to draw the right side
draw(); // draw traces in right side path
forward(side); // forward to top of the triangle now
halt(); // halt the process, here its your triangle
}
I don't have the following function but I have done according to requirement. If you provide some file where those function has been defined then i will give you executable program. But if that file is not present this program will work but not executable.
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.