#include #include /* This library contains the sqrt function */ /* This program computes the solutions to a quadratic equation of the form Ax^2 + Bx + C where the user inputs values for A, B, and C. It does so using the formula: _________ -B +- VA^2 - 4AC ---------------- 2A */ main() { /* We will need float values for most of these. */ float A, B, C, x; /* Since this is a fairly complex program, we will include some detailed instructions on what will be input */ cout << "This program computes solutions to a quadratic equation of the form\n" << "\tAx^2 + Bx + C\n" << "where you enter the values of A, B, and C.\n\n"; /* Prompt for input */ cout << "Enter value of A: "; cin >> A; cout << "Enter value of B: "; cin >> B; cout << "Enter value of C: "; cin >> C; /* Compute and print first solution */ x = (-B + sqrt(B * B - 4 * A * C))/(2 * A); cout << "One solution for x is " << x << "\n"; /* Compute and print first solution */ x = (-B - sqrt(B * B - 4 * A * C))/(2 * A); cout << "The other solution for x is " << x << "\n"; }