1) Define a struct to store fractions like a/b where a is numerator and b is denominator and a and b are integers. Example: 1/2, 4/5, etc.. 2) Write a function which takes two fractions as input parameters and returns the sum of these fractions which is another fraction. For example: If the input fractions are 1/2 and 2/5, Then the function should return 9/10 as a fraction. If the input fractions are 1/4 and 2/4, Then the function should return 3/4 as a fraction. In general: a/b + c/d = (a + c) / b if b = d a/b + c/d = (ad + bc) / (bd) otherwise 3) In main function: - Take two fractions from the user. You need to get two integers from user for each fraction. - Send two fractions to your function and get the result returned from the function. - Print the result in a/b format.
c
1) Define a struct to store fractions like a/b where a is numerator and b is denominator and a and b are integers.
Example: 1/2, 4/5, etc..
2) Write a function which takes two fractions as input parameters and returns the sum of these fractions which is another fraction.
For example:
If the input fractions are 1/2 and 2/5,
Then the function should return 9/10 as a fraction.
If the input fractions are 1/4 and 2/4,
Then the function should return 3/4 as a fraction.
In general:
a/b + c/d = (a + c) / b if b = d
a/b + c/d = (ad + bc) / (bd) otherwise
3) In main function:
- Take two fractions from the user. You need to get two integers from user for each fraction.
- Send two fractions to your function and get the result returned from the function.
- Print the result in a/b format.
![](/static/compass_v2/shared-icons/check-mark.png)
Trending now
This is a popular solution!
Step by step
Solved in 3 steps with 3 images
![Blurred answer](/static/compass_v2/solution-images/blurred-answer.jpg)
![Computer Networking: A Top-Down Approach (7th Edi…](https://www.bartleby.com/isbn_cover_images/9780133594140/9780133594140_smallCoverImage.gif)
![Computer Organization and Design MIPS Edition, Fi…](https://www.bartleby.com/isbn_cover_images/9780124077263/9780124077263_smallCoverImage.gif)
![Network+ Guide to Networks (MindTap Course List)](https://www.bartleby.com/isbn_cover_images/9781337569330/9781337569330_smallCoverImage.gif)
![Computer Networking: A Top-Down Approach (7th Edi…](https://www.bartleby.com/isbn_cover_images/9780133594140/9780133594140_smallCoverImage.gif)
![Computer Organization and Design MIPS Edition, Fi…](https://www.bartleby.com/isbn_cover_images/9780124077263/9780124077263_smallCoverImage.gif)
![Network+ Guide to Networks (MindTap Course List)](https://www.bartleby.com/isbn_cover_images/9781337569330/9781337569330_smallCoverImage.gif)
![Concepts of Database Management](https://www.bartleby.com/isbn_cover_images/9781337093422/9781337093422_smallCoverImage.gif)
![Prelude to Programming](https://www.bartleby.com/isbn_cover_images/9780133750423/9780133750423_smallCoverImage.jpg)
![Sc Business Data Communications and Networking, T…](https://www.bartleby.com/isbn_cover_images/9781119368830/9781119368830_smallCoverImage.gif)