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