In: Computer Science
Write a program that computes the product of two fractions. The user provides 4 input which represent the numerator and the denominator of two fractions and prints the result of the operation. The program uses two functions. One called MultiplyNumerator(…) which calculates the product of the numerators of the fractions, and a second one called MultiplyDenom(…) which calculates the product of the denominator of the fractions. Call your program MultiplyFrac.cpp
hello,
let me provide you the code for your problem:-
code starts here:-
#include <iostream>
using namespace std;
int MultiplyNumerator(int a,int b)
{
return a*b;
}
int MultiplyDenom(int a,int b)
{
return a*b;
}
int main()
{
int
numerator1,numerator2,denominator1,denominator2;
int numerator_result,Denominator_result;
cout<<"Enter Numerator of First Function:
";
cin>>numerator1;
cout<<"Enter Denominator of First
Function: ";
cin>>denominator1;
cout<<"Enter Numerator of Second Function:
";
cin>>numerator2;
cout<<"Enter Denominator of Second
Function: ";
cin>>denominator2;
numerator_result=MultiplyNumerator(numerator1,numerator2);
Denominator_result=MultiplyDenom(denominator1,denominator2);
cout<<"The Product of two function will be
"<<numerator_result<<"/"<<Denominator_result<<"
OR "<<(double)numerator_result/Denominator_result;
}
code ends here:-
providing you the snapshot of the code to reduce the confusion in indentation of the code:-
providing you the sample output of the code:-
i hope i was able to solve your problem to a greater extent, please feel free to comment your queries, i will surely respond to them.
Please consider my efforts and upvote my solution.
Thanku:)