Question: Write a program in C++ language that reduces fractions. Ask the user to enter two positive integers: the numerator, and the denominator. Then print the

Write a program in C++ language that reduces fractions. Ask the user to enter two positive integers: the numerator, and the denominator. Then print the original fraction and its fully reduced equivalent. For example (users input is bold):

Enter the numerator: 100

Enter the denominator: 75

100/75 = 4/3

Hints: As with any non-trivial program, you should write this in stages, getting each stage tested and working before going on to the next. Heres a suggested plan:

1. Write the gcd function and test it from main().

2. Write the reduce function. Of course, reduce should call gcd. Dont worry about special cases.

3. Add code in main()to deal with special cases.To deal with a negative numerator and/or denominator, before beginning to reduce the fraction, check if the fraction will be negative, and if so, output a negative sign.Then change both numbers to positive, reduce the fraction, and output the reduced numerator and denominator.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!