Question: C++ A quadratic() Function Write a function called quadratic() that finds both roots of the quadratic equation. The main() function prompts and inputs the values
C++
A quadratic() Function
Write a function called quadratic() that finds both roots of the quadratic equation. The main()
function prompts and inputs the values for a, b and c.
If a is zero, display an error message to cerr and return false. If the discriminant is negative, display an error message to cerr and return false. Otherwise, calculate the two roots and return true. The function prototype is
bool quadratic (double a, double b, double c, double & root1, double & root2);
Next write a main() function that inputs a trio of values for a, b and c. Then, main() calls
quadratic(). If there are roots, main() displays the two roots. Note that the only displaying that is done within the quadratic() function is to cerr for error messages.

A quadratic) Function Write a function called quadratic) that finds both roots of the quadratic equation. The main() function prompts and inputs the values for a, b and c. If a is zero, display an error message to cerr and return false. If the discriminant is negative, display an error message to cerr and return false. Otherwise, calculate the two roots and return true. The function prototype is bool quadratic (double a, double b, double c, double & root1, double & root2); Next write a main() function that inputs a trio of values for a, b and c. Then, main() calls quadratic). If there are roots, main() displays the two roots. Note that the only displaying that is done within the quadratic) function is to cerr for error messages
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
