This lab presents a few exercises on conditionals. You will develop two separate programs for this lab. You can get support files by downloading lab3.zip. This zip file will unpack to create a directory named lab3. Within that directory you will find two subdirectories corresponding to the two programs that you must write.
Develop the following programs in the files specified for each part. To compile your program, in the respective directory, type make debug for the debug version and make run for the run version.
As always, you must develop test cases for the functions that you write. It is recommended that you develop these test cases before you write the code for each function. Place the test cases in the test_cases function. You are writing separate programs so each program must contain a test_cases function.
Develop a program in a file named quadratic.c (in the lab3/quadratic directory). As part of this program, develop a function named real_roots that determines if the roots of a quadratic equation (see the section about the discriminant) are real or imaginary. If the roots are real, then the function will return true (1 in C). Otherwise it should return false (0 in C).
In the main function, prompt the user for the coefficients of a quadratic equation (i.e., prompt for the values of a, b, and c), invoke the real_roots function, and then print to notify the user that the roots are either real or imaginary.
Next print the results of the quadratic equation. You will need to use the result of real_roots to determine if you will print a real number (as a double) or an imaginary number. You will also need to determine the number of roots to print.
Give careful consideration to how you structure your solution. You should avoid duplicated code (code that does the same thing) and try to limit the number of times the same computation is performed.
Develop a program in a file named circle_collision.c (in the lab3/circle_collision directory). As part of this program, develop a function named circle_collision_test that determines if two circles overlap in two-dimensional space. For this program, a circle will be defined by a position (x,y coordinates) and a radius. As such, the circle_collision_test function must take, as parameters, the position and radius for two circles. The function returns true if the circles overlap and false otherwise.
In the main function, prompt the user for the position and radius for each of two circles, invoke the circle_collision_test function, and then print to notify the user that the circles either do or do not overlap. (If you are not sure how to determine if two circles overlap, consider how you might use the distance between their centers.)
Note that this kind of test is useful in a virtual context (such as a game) to determine if two actors in the two-dimensional space have collided (and sphere collisions, very similar to what you are doing here, are used to improve performance when checking if two non-spherical objects collide).
Demonstrate your work to your instructor to have this lab recorded as completed.