A Quadratic Equation Solver - The Algorithm
The problem Write a program to calculate the roots of a quadratic equation of the form:The roots are given by the following formula
The algorithm
- READ values of a, b and c,
- if a is zero then stop as we do not have a quadratic,
- calculate value of discriminant
- if D is zero then there is one root: ,
- if D is > 0 then there are two real roots: and ,
- if D is < 0 there are two complex roots: and ,
- PRINT solution.