Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

write C program Write a program named sumfrac.c that prompts the user to enter two fractions, each of the form n/d. The program then adds

write C programimage text in transcribed

Write a program named sumfrac.c that prompts the user to enter two fractions, each of the form n/d. The program then adds the fractions together and displays the resulting fraction. You don't have to reduce the answer. The key thing here is C doesn't know anything about fractions. It only knows about integers, floating- point numbers, and characters. You'll have to handle the fractions yourself by keeping track of the numerators and denominators in separate variables. For this assignment you'll need two variables for the input numerators, two for the input denominators, and two for the sum (numerator and denominator). The formula for adding two fractions and is a.d+cob b.d Your program should prompt the user to enter each fraction as two integers separated by a slash on the same line. Do not prompt for the numerator and denominator separately. This program will help you learn to use scanf's built-in pattern matching. The output should be the sum displayed as a fraction using a slash. Again, you don't need to reduce the fraction, but can if you want to. It's not required for this program. Example: (note: user input in shown in bold to make it easier to see; your program won't use bold to display any of the text) This program will sum two fractions. Input the first fraction: 3/5 Input the second fraction: 7/9 The sum is: 62/45

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: 3

blur-text-image

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

The Database Experts Guide To Database 2

Authors: Bruce L. Larson

1st Edition

0070232679, 978-0070232679

More Books

Students also viewed these Databases questions

Question

Make efficient use of your practice time?

Answered: 1 week ago

Question

Define Administration?

Answered: 1 week ago

Question

=+ For what reasons can and do unions go on strike?

Answered: 1 week ago