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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started