Question: C Program : Quadratic Equation Solver Write a program to compute the real roots of a quadratic equation in the form ax^2 + bx +
C Program : Quadratic Equation Solver
Write a program to compute the real roots of a quadratic equation in the form
ax^2 + bx + c.
Your program should prompt the user to enter the constants (a, b, and c) as floating point numbers. It is then to display the roots based on the following rules:
If both a and b are zero, print that there is no solution.
If a is zero (and b is non-zero), there is only one root (-c/b). It should be calculated and printed to three decimal places.
If the discriminant (b^2 4ac) is negative, print that there are no real roots.
For all other combinations there are two roots, which should be calculated from the formulas below and printed with three decimal places.
x1 = -b + (b^2 -4ac)^0.5
2a
x2 = -b - (b^2 -4ac)^0.5
2a
Find a way to do this program that uses if structures other than just simple if.
Run your program with the following data:
Set 1: a=3.0; b=8.0; c=5.0;
Set 2: a= 6.0; b=7.0; c=8.0;
Set 3: a=0.0; b= 9.0; c= -10.0;
Set 4: a=0.0; b=0.0; c=11.0;
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
