- Declare Double Variables Num1 Den1 Num2 And Den2 And Read Each Variable From Input In That Order Find The Differenc 1 (81.6 KiB) Viewed 77 times
Declare double variables num1, den1, num2, and den2, and read each variable from input in that order. Find the differenc
-
- Site Admin
- Posts: 899603
- Joined: Mon Aug 02, 2021 8:13 am
Declare double variables num1, den1, num2, and den2, and read each variable from input in that order. Find the differenc
Declare double variables num1, den1, num2, and den2, and read each variable from input in that order. Find the difference of the fractions num1/den1 and num2/den2 and assign the result to fraction Difference. The calculation is: difference = num1 den₁ Ex: If the input is 1.5 3.5 4.0 4.5, the output is: -0.46 Note: Assume that den1 and den2 will not be 0. 5 int main() { 6 7 double num1; 8 double den1; 9 double num2; double den2; 10 11 12 13 14 15 16 17 18 19 num2 den2 double fractionDifference; cin >> num1; cin >> den1; cin >> num2; cin >> den2; fractionDifference = (num1/den1) - (num2-den1); cout << fixed << setprecision (2) << fractionDifference << endl;