CSCI 1300 Exam 2 Practice
These are practice problems for the second exam. In each case, your answer should be a function (not a complete program). For the problems that involve graphics, you may always use these items:
bgiout << "Michael";
outstreamxy(px, py);
The same idea may be used with any other name.
The size of the chessboard is n by n (where n is a parameter to the function).
There are three cases to worry about: (1) When a=0 the function should print "Be careful with zeros!" (2) When b*b-4*a*c<0 it should print "Don't want to deal with complex numbers!". (3) Otherwise the function must compute and print the two roots of the equation.
If the ant is starting on a black pixel, then it will do these things: Change the pixel to white, turn 90 degrees counterclockwise, and move forward one square.
If the ant is starting on a pixel square, then it will do these things: Change the pixel to black, turn 90 degrees clockwise, and move forward one square.
P.S. If you write a main program that calls this function repeatedly, you'll get very interesting patterns described as Langton's Ant.