Answer:
1: #include <iostream>
2: using namespace std;
3: int main()
4: {
5: int a,b,c,d;
6: cout<<"n1: ";
7: cin>>a;
8: cout<<"d1: ";
9: cin>>b;
10: cout<<"n2: ";
11: cin>>c;
12: cout<<"d2: ";
13: cin>>d;
14: int top = (a*d)+(b*c);
15: int bottom = b*d;
16: cout<<"Sum: "<<top<<"/"<<bottom<<"\n";
17: top = (a*d)-(b*c);
18: cout<<"Difference: "<<top<<"/"<<bottom<<"\n";
19: top = a*c;
20: cout<<"Product: "<<top<<"/"<<bottom<<"\n";
21: top = a*d;
22: bottom = b*c;
23: cout<<"Quotient: "<<top<<"/"<<bottom<<"\n";
24: return 0;
25: }
Explanation:
The Program is written in C++ programming language
The Program is left numbered
Line 5 was used for variable declaration.
Variables a,b represents the numerator and denominator of the first fraction
While variables c,d represent the numerator and denominator of the second fraction
Line 6 prints "n1" without the quotes which represents the numerator of the first fraction
Line 7 accepts input for the numerator of the first fraction.
Line 8 prints "d1" without the quotes which represents the denominator of the first fraction
Line 9 accepts input for the denominator of the first fraction.
Line 10 prints "n2" without the quotes which represents the numerator of the second fraction
Line 11 accepts input for the numerator of the second fraction.
Line 12 prints "d2" without the quotes which represents the denominator of the second fraction
Line 13 accepts input for the denominator of the second fraction.
Line 14 and 15 calculate the sum of the fractions which is then printed on line 16
Line 17 calculates the difference of the fractions which is then printed on line 18
Line 19 calculates the product of the fractions which is then printed on line 20
Line 21 and 22 calculates the quotient of the fractions which is then printed on line 23