C Program To Find All Roots of A Quadratic Equation
C Program To Find All Roots of A Quadratic Equation
To understand this example, you should have the knowledge of following C programmingtopics:
C Programming Operators
C if...else Statement
The standard form of a quadratic equation is:
ax2 + bx + c = 0, where
a, b and c are real numbers and
a ≠ 0
The term b2-4ac is known as the determinant of a quadratic equation. The determinant tells the nature
of the roots.
If determinant is greater than 0, the roots are real and different.
If determinant is equal to 0, the roots are real and equal.
If determinant is less than 0, the roots are complex and different.
Example: Program to Find Roots of a Quadratic Equation
#include <stdio.h>
#include <math.h>
int main()
{
double a, b, c, determinant, root1,root2, realPart, imaginaryPart;
determinant = b*b-4*a*c;