Here's the relevant parts:

Expand|Select|Wrap|Line Numbers

- double a, b, c, root1, root2;
- cout << "Enter the 3 coefficients of the quadratic equation." << endl;
- cin >> a >> b >> c;
- if(cin)
- {
- cout << "Last input was successful." << endl;
- cout << a << "x" << (char)253 << " + " << b << "x + " << c << endl;
- root1 = (-b + sqrt(pow(b,2)+4*a*c)) / (2*a);
- root2 = (-b - sqrt(pow(b,2)+4*a*c)) / (2*a);
- if(root1 && root2)
- cout << "There are two real roots." << endl;
- else if(root1 || root2)
- cout << "There is one real root." << endl;
- else cout << "All roots are complex numbers." << endl;
- if(root1)
- cout << "Root 1 = " << root1 << endl;
- if(root2)
- cout << "Root 2 = " << root2 << endl;
- }
- else
- cout << "Last input was unsuccessful. Check your data and try again." << endl;