Question: (a) Write a function for computing the roots using the following function header: int compute_roots (double a, double b, double c, doubles x1, double&

(a) Write a function for computing the roots using the following function

header: int compute_roots (double a, double b, double c, doubles x1, double&

(a) Write a function for computing the roots using the following function header: int compute_roots (double a, double b, double c, doubles x1, double& x2) The arguments a, b, c are the coefficients of the quadratic equation, and x1 and x2 are possible computed roots of the equation (depending on the return value). The return value of this function could be one of the numbers: 0 == no roots 1 == one root 2 == two real roots 3 == infinite number of roots 4 == no real roots You should save the return value in a variable, say, nroots and use it later in a switch statement switch (nroots). Do not include any input or output statement inside compute_roots(). All input/output statements should be in main () only. (b) Test your function in main () for five different quadratic equations. Use the included flow chart when writing the function. Flowchart for ax+bx+c=0 Input a, b, c a=0 No b-4ac A20 No Yes Yes X2--6/2a+1 A/28 x2--8/28-13/2a (degenerative case) Yes Yes b=0 No x = -c/b Linear equation i 4-0 Yes c=0 (Compute Discriminant) No Solutions XI-(-8-/5/28 22-(-8-/5/28 No or No Two Complex Real Roots Roots x=-b/2a Infinite # of roots Two Real Roots Double Root

Step by Step Solution

3.36 Rating (162 Votes )

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock

The detailed ... View full answer

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 Programming Questions!