Algorithm for Roots of a Quadratic
The roots of a quadratic equation
ax^2 + bx + c = 0can be determined with the quadratic formula,
\begin{matrix}x_{1} \\ x_{2} \end{matrix}= \frac{- b \pm \sqrt{|b^2 - 4ac|} }{2a} (E2.1.1)
Develop an algorithm that does the following:
Step 1: Prompts the user for the coefficients, a, b, and c.
Step 2: Implements the quadratic formula, guarding against all eventualities (for example, avoiding division by zero and allowing for complex roots).
Step 3: Displays the solution, that is, the values for x.
Step 4: Allows the user the option to return to step 1 and repeat the process.