COSC 1435 Lab 10
Purpose: To practice writing functions
Due: Before class April 15, 2013
Requirements: This lab is designed to introduce functions. We will be building on what you accomplished in lab 6, by adding the capability to reduce fractions and turning improper fractions to proper fractions. Additionally, if you received a grade less than you wanted for lab 6, this is your opportunity to resubmit lab 6. We will be using Euclids algorithm to do. Do the following:
1. Review your lab 6 program and verify that it works properly. Add validation using a while loop to your program to verify that 0 is not allowed in the denominator of either fraction. Add a do-while loop to your lab 6 to allow the user to add and multiply multiple fractions. Verify that your program works properly, before continuing on with the next step. Ask for help, if it does not.
2. We will be using Euclid's Algorithm to reduce our functions. Here is a complete test program that uses Euclid's Algorithm. This function uses recursion to accomplish the task. Recursion means that the program calls itself. For those going on in computer science, you will learn more about recursion in COSC 1436.
3. Add euclid function to your lab 6 program. Remember you will need include both the function definition and the function prototype. Recompile your program to verify it works properly. Now add code into your program that uses the euclid function to reduce all the fractions. Send the numerator and the denominator of a fraction to the euclid function and it will return the greatest common factor. If you then divide both the numerator and denominator by this common factor, your fraction will be reduced. If the fraction cannot be reduced, it will be unchanged.
4. Next add code that will handle improper fractions. We will develop the pseudocode to do this in the lab.
Program Submission. You will be submitting this lab via Blackboard. Prepare the following:
Submit via blackboard following the instructions given during the lab.