Question
Quadratic Equations Given a quadratic equation in standard form, , solutions for x can be determined using the quadratic formula, . The values of x
Quadratic Equations
Given a quadratic equation in standard form, , solutions for x can be determined using the quadratic formula, . The values of x can be real or complex. The discriminant, , is used to determine the nature of the root(s). If the discriminant is negative, there will be no real roots. If the discriminant is 0, there will be one real root. In the third case, a positive discriminant will yield two real roots. (Real roots are of particular interest in solving physical world problems.)
Write a function that will determine the number of real roots for a quadratic equation as well as calculate any real roots. The function prototype should be:
| ||
int calcQuadraticRoots(double a, double b, double c, double& x1, double& x2); |
where a, b, and c represent the coefficients from the standard form of the quadratic equation and x1 and x2 represent the possible real roots.
If the number of real roots is zero, the function should return 0 without assigning values to x1 and x2. If the number of real roots is one, the function should assign the value of the real root to x1 and return 1. If the number of real roots is two, the function should assign the larger value to x1 and the smalle value to x2 and return 2.
Include driver code in function main() to test this function thoroughly. Your driver code should display the values of the coeffients of the quadratic equation, the number of roots of the quadratic equation as well as the roots of the quadratic equation.
I am learning C++ right now.
I am learning parameter, void.
Thank you for your helping!
Your program should not prompt the user to enter any information.
Although not required by this assignment, any additional functions you create would help to demonstrate your grasp of the concepts of top-down design and modular coding.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started