Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- int main()
- {
- int a, b, c, d;
- cout << "Enter the value of coefficient a: ";
- cin >> a;
- if (a == 0)
- {
- cout << "Error! The value of a is 0!\n";
- return 0;
- }
- else
- {
- cout << "Enter the value of coefficient b: ";
- cin >> b;
- cout << "Enter the value of coefficient c: ";
- cin >> c;
- }
- d = b * b - 4 * a * c;
- if (d < 0)
- {
- cout << "No real roots!\n";
- return 0;
- }
- else
- {
- cout <<"Real root 1: " <<(-b + d) / (2 * a) << endl;
- cout <<"Real root 2: " <<(-b - d) / (2 * a) << endl;
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement