Question
i need to write a C++ program For this program you are to write a simple function to find the roots of quadratic equations. The
i need to write a C++ program
For this program you are to write a simple function to find the roots of quadratic equations. The function proto type should be:
int roots(double, double, double, double &, double &, double &, double &); the first three parameters should be the coefficients of the quadratic polynomial. The first, the x ^2 coefficient, should be non-zero, in this case roots should return 1, if the x ^2 coefficient is zero roots should return 0. If the x ^2 coefficient is non-zero the roots should be returned in the last four reference parameters. The forth parameter should contain the real part, and the fifth the imaginary part of one solution. The sixth the real and the seventh the imiginary part of the other root. If the x^ 2 coefficient is zero the last four parameters should not have their values changed. In addition there should be no output satatments in your function roots.
Notice that to test your function, you will also need to write a main() function to call the roots function with the appropriate parameters. If the x^ 2 coefficient is zero, your program should output that the equation is not quadratic, otherwise your program should output the two roots. Also you may wish to use the sqrt() function, in this case you may need to inculde the cmath header file.
Test data for you program
2x ^2 + 10x + 1 = 0
x ^2 1 = 0
x^ 2 2x + 1 = 0
5x^2 + 1x + 7 = 0
3x + 5 = 0
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