// Solving ax^2 + bx + c = 0 #include #include using namespace std; const double a=1., b=3., c=-4.; // constant variables // & initial values double D, x1, x2; int main() { D = b*b-4.*a*c; // determinant if (D>=0){ x1 = (-b + sqrt(D))/(2.*a); // 1st root x2 = (-b - sqrt(D))/(2.*a); // 2nd root cout << x1 << " " << x2 << endl; } }