Question: Chapter 4 in C + + Write a program that reduces a fraction to lowest terms. Two functions should be implemented. Function gcd should find

Chapter 4
in C++ 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.
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
2835
Enter the denominator
greatest common denominator is 7
your fraction reduced is 45
Try Again? (1= yes, 0= exit)
1
Enter the numerator
85
Enter the denominator
1210
greatest common denominator is 5??
your fraction reduced is 172422
Try Again? (1= yes, 0= exit)
Enter the numerator
289
Enter the denominator
5148
greatest common denominator is 1
your fraction reduced is 289/51
Try Again? (1= yes, 0= exit
 Chapter 4 in C++ Write a program that reduces a fraction

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!