Question: #include #include using namespace std; // Function prototypes int quadratic(double a, double b, double c, double& r1, double& r2); void getInput(double& a, double& b, double&

#include #include using namespace std; // Function prototypes int quadratic(double a, double b, double c, double& r1, double& r2); void getInput(double& a, double& b, double& c); int main() { double a, b, c, r1, r2; getInput(a, b, c); if (quadratic(a, b, c, r1, r2)) { cout << "The roots are: " << r1 << " and " << r2 << endl; } else { cout << "No real roots exist." << endl; } return 0; } // Function to get input from the user void getInput(double& a, double& b, double& c) { cout << "Enter values for a, b, and c: "; cin >> a >> b >> c; } // Function to calculate the roots of the quadratic equation int quadratic(double a, double b, double c, double& r1, double& r2) { double discriminant = b * b - 4 * a * c; if (discriminant > 0) { r1 = (-b + sqrt(discriminant)) / (2 * a); r2 = (-b - sqrt(discriminant)) / (2 * a); return 1; } else if (discriminant == 0) { r1 = r2 = -b / (2 * a); return 1; } else { return 0; // No real roots } }

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Mathematics Questions!