# C Program to find the roots of a Quadratic equation

An equation of the form:

$ax^2+bx+c=0$

is known as a quadratic equation, where a, b and c are numbers and a is not equal to 0. The values of x  which satisfies the equation are known as the roots of the equation.

To calculate the roots of a quadratic equation we use the following formula:

$x=\frac{-b^2 \pm \sqrt{b^2-4ac}}{2a}$

where $\sqrt{b^2 - 4ac}$ is called the discriminant.

If discriminant > 0, then the equation has two distinct real roots.

If discriminant = 0, then the roots of the equation are real and same.

If discriminant < 0, then the roots of the equation are imaginary.

The following is a C program which computes the roots of the quadratic equation:

Expected Output:

1st run:

2nd run:

Related Programs: