Question
you are to extend the fraction multiplication examples given in class to perform fraction addition (using struct only, not classes). Each fraction only consists of
you are to extend the fraction multiplication examples given in class to perform fraction addition (using struct only, not classes). Each fraction only consists of a numerator and a denominator. The program will query the user for 2 fractions and then perform the addition. It should ask the user to provide another set of fractions to perform until the denominator of either fraction entered is 0.
For example if the user enters 2 3 1 3, it means that the 2 fractions are 2/3 and 1/3. The sum of these two fractions would be 1 / 1. Please make sure the sum is written in thereduced form (but not mixed fraction). In the above example, 3 / 3 is not reduced. Furthermore, if the result is 9/6, the reduced form is 3/2. You donotneed to convert it to a mixed fraction.
In your program, you must usestruct fractiondata type, as in the lectures. When computing the sum, use a sum() function:
fraction sum(fraction f1, fraction f2)
Example execution:
Please enter 2 fractions (numerator denominator): 2 3 1 3
The sum is 1 / 1
Please enter 2 fractions (numerator denominator): 2 3 3 4
The sum is 17 / 12
Please enter 2 fractions (numerator denominator): 2 9 5 6
The answer is 19 / 18
Please enter 2 fractions (numerator denominator): 3 8 1 6
The answer is 13 / 24
Please enter 2 fractions (numerator denominator): 2 0 1 3
Good bye
please show the explanation and comments and give you an upvote
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