The general form of the quadratic equation can be written as follows:

where a, b and c are known real numbers, called equation coefficients. In order to calculate the roots of this equation, or to find solutions, we will use generally known formulas:

or

When

the equation has no solution.

Implementation of the algorithm in: Pascal, C++, Java, Python, JavaScript

Description of the algorithm:

- Start - our algorithm starts here.
- We load input data - coefficients a, b and c of the equation.
- We check if the coefficient a of the equation is equal to 0.
- If a = 0 we deal with a linear equation, we invoke the algorithm of solving the linear equations.
- We calculate the delta value.
- We check if the delta is less than 0.
- If delta <0 we print information, the equation has no solutions.
- We check if the delta is equal to 0.
- If delta = 0, we calculate the value of one double solution x.
- When delta = 0, after calculating x, we write its value.
- We reach this point when none of the previous conditions have been met (delta <0 and delta = 0), i.e. when delta> 0. We calculate the values of two solutions of the equation: x
_{1}and x_{2}. - We print the calculated values of both solutions.
- Stop - the end of the algorithm common to all roads.