Question
Write a program that reduces a fraction to lowest terms. Two functions should be implemented. Function gcd should find and return the greatest common denominator
Write a program that reduces a fraction to lowest terms. Two functions should be implemented. Function gcd should find and return the greatest common denominator and be called as g = gcd(num,den);. Function reduce(num,den); should call gcd to provide the lowest terms. The lowest terms should be returned via reference in num and den. (in c++) Pseudo code for gcd is: function gcd(a, b) while b 0 t = b b = a mod b a = t return a Example Output: This program takes a numerator and denominator and reduces to lowest terms Enter the numerator 28 35 Enter the denominator greatest common denominator is 7 your fraction reduced is 4/5 Try Again? (1 = yes, 0 = exit) 1 Enter the numerator 85 Enter the denominator 1210 greatest common denominator is 5 your fraction reduced is 17/242 Try Again? (1 = yes, 0 = exit) 1 Enter the numerator 289 Enter the denominator 5148 greatest common denominator is 1 your fraction reduced is 289/5148 Try Again? (1 = yes, 0 = exit) 1 Enter the numerator 306 Enter the denominator 697 greatest common denominator is 17 your fraction reduced is 18/41 Try Again? (1 = yes, 0 = exit) 0
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