Assume that the fraction structurecontains two members: numerator and denominator (both of type int). Writefunctions that perform
Question:
Assume that the fraction structurecontains two members: numerator anddenominator (both of type int). Writefunctions that perform the following operations on fractions:
a) Reduce the fraction f to lowestterms. Hint: To reduce a fraction to lowest terms, first computethe greatest common divisior (GCD) of the numerator anddenominator. Then divide both the numerator and denominator by theGCD.
b) Add the fractions f1 andf2.
c)Subtract the fractions f2 from thefraction f1.
d) Multiply the fractions f1 andf2.
e) Divide the fractions f1 by thefraction f2.
The fractions f, f1, andf2 will be arguments of typestruct fraction; each function willreturn a value of type struct fraction.The fractions returned by the functions in parts (b)-(e) should bereduced to lowest terms. Hint: You may use the function from part(a) to help write the functions in parts (b)-(e).
Income Tax Fundamentals 2013
ISBN: 9781285586618
31st Edition
Authors: Gerald E. Whittenburg, Martha Altus Buller, Steven L Gill