Write a complete program that prompts the user for the coefficients a, b, and c of a quadratic equation
ax2 + bx + c = 0 and outputs the solutions as shown. discriminant = b2
Use single precision floating point.
1. main() – prompt the user for a, b, and c, call solveqe to solve the equation, and display the results using the
return value from solveqe.
2. int solveqe(float a, float b, float c) – solve for solutions, return status in v0:
0: not quadratic,
1: 1 solution, x in f0, or
2: 2 solutions, x1, x2 in f0 and f1.
b. Must call sqrt to compute the square root.
c. Must be a reentrant subprogram and use register call convention.
3. float sqrt(float x) – return the square root of x
Quadratic Equation Solver by F. Last
Enter values for a? #
Enter values for b? #
Enter values for c? #
is a blank line. F. Last is your first initial and last name, # is user input.
1. If a = 0 && b = 0:
Not a quadratic equation.
2. If a = 0 and b != 0, linear equation, x = -c / b
x = #.#
3. If discriminant < 0:
Roots are imaginary.
x1 = #.#
x2 = #.#
#.# are replaced with calculated root(s)
if a = 0
if b = 0
return 0 (v0)
x = -c / b
return 1, x (v0, f0)
d = b2
if (d < 0)
return -1 (v0)
compute x1 and x2
return 2, x1, x2 (v0, f0, f1)
* ONLY main will output anything
* sovleqe and sqrt DO NOT output anything.
* sqrt.f can be used in procedure sqrt or you can implement your own
3 freelancer chào giá trung bình$27 cho công việc này
Hi There, I am an embedded system expert and an electronics engineer having expertise in assembly, MIPS, SIMD, Verilog and vhdl. just share your further details if you have some deadline to work on. Thanks