Ask Experts Questions for FREE Help!
 

Free Answers in 3 Easy Steps

Register Now
3 Steps
 


Ask QuestionsprogressAnswer QuestionsprogressBuild ReputationprogressBecome an Expert
 
At Ask Me Help Desk you can ask questions in any topic and have them answered for free by our experts. To ask questions or participate in answering them you must register for a free account. By registering you will be able to:
  • Get free answers from experts in any of our 300+ topics.
  • Accept money for answers that you provide.
  • Communicate privately with other members (PM).
  • See fewer ads.
  View Answers    Answer this question    Ask a question  
 

Bill9_21
Feb 8, 2012, 01:56 AM
Modify the program so that the user enters both fractions at the same time, separated by a plus sign:

Enter two fractions separated by a plus sign: 1/2 1/4

The sum is 3/4



#include
#include

Int main(void)
{
Int num1, denom1, num2, denom2, result_num, result_denom;

Printf("Enter first fraction: ");
Scanf("%d/%d", &num1, &denom1);

Printf("Enter second fraction: ");
Scanf("%d/%d", &num2, &denom2);

Result_num = num1 * denom2 num2 * denom1;
Result_denom = denom1 * denom2;
Printf("The sum is %d/%d\n", result_num, result_denom);

Return 0;
}