// quad.cpp for CS11 lab 3. // Using functions to compute the roots of a quadratic equation #include #include #include // Discriminant means: the square root of (b*b - 4*a*c) // Root 1 means: (-b + discriminant) / (2*a) // Root 2 means: (-b - discriminant) / (2*a) // The prototype for the quad function is given here: void quad (double a, double b, double c); // Additional function prototypes -- Complete the following: discriminant(); root1(); root2(); int main() { double a, b, c; // Get input from the user. cout << "Enter coefficients for quadratic equation: "; cin >> a, b, c; // Now, apply the quadratic formula for these coefficients. quad (a, b, c); return 0; } // This function solves the quadratic equation given the coefficients // a, b and c that were passed from the main function. void quad(double a, double b, double c) { double r1, r2; // Perform computations by calling specific functions. // Complete the assignments statements for r1 and r2: r1 = root1; r2 = root2; // Ready for output. cout << setprecision(4) << setiosflags (ios::fixed | ios:: showpoint); cout << "The roots of " << a << "x**2 + " << b << "x + " << c << " are " << r1 << " and " << r2 << endl; return; } // Complete the following function implementations: discriminant() { return ; } root1() { return ; } root2() { return ; }