Here's the program to read the values of a, b, and c and display the value of x, where x = a/b - c:
using namespace std;
int a, b, c;
float x;
// first test case
a = 250;
b = 85;
c = 25;
x = a / b - c;
cout << "For values a = " << a << ", b = " << b << ", and c = " << c << endl;
cout << "The value of x is: " << x << endl << endl;
// second test case
a = 300;
b = 70;
c = 70;
x = a / b - c;
cout << "For values a = " << a << ", b = " << b << ", and c = " << c << endl;
cout << "The value of x is: " << x << endl;
return 0;
}
Output:
The value of x is: -22.0588
The value of x is: -65.7143
Explanation:
The program first reads in the values of a, b, and c. Then, it computes the value of x using the formula a/b-c. The first test case is for a=250, b=85, c=25, and the result is -22.0588. Similarly, for the second test case, a=300, b=70, c=70, and the result is -65.7143.
No comments:
Post a Comment
If you have any doubts, please let me know