Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_step_2

Step: 3

blur-text-image_step3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Knowledge Discovery In Databases

Authors: Gregory Piatetsky-Shapiro, William Frawley

1st Edition

ISBN: 0262660709, 978-0262660709

More Books

Students also viewed these Databases questions

Question

What are the basic duties of a bailee?

Answered: 1 week ago