write a c program of An equation of the form ax2 + bx + c = 0 is known as the quadratic equation.
The values of x that satisfy the equation are known as the roots of the equation.
A quadratic equation has two roots which are given by the following two formula
root1=-b+sqrt(b2 -4ac) /2a
root2=-b-sqrt(b2 -4ac) /2a
a quadratic equation, depending on whether the expression inside the square root sign, (b2 – 4ac) , is positive, negative, or zero. This expression has a special name: the discriminant.
printf("Input values of a, b, and c\n");
printf("\n discriminant = %f\n",d);
if(d < 0)
printf("\n Roots are Imaginary\n");
rootl = (-b + sqrt(d))/(2.0*a);
root2 = (-b - sqrt(d))/(2.0*a);
printf("\n\nRootl = %5.2f\n\nRoot2 = %5.2f\n", rootl,root2 );
OUTPUT of program ax2 + bx + c = 0 , A quadratic equation.
discriminant is positive if b2 -4ac > 0
then the quadratic equation has two solutions.
discriminant is zero if b2 – 4ac = 0
then the quadratic equation has one solution.
discriminant is negative if b2 -4ac < 0
then the quadratic equation has no solutions.
C program run First Time
Input values of a, b, and c
2 4 -16
discriminant = 144.000000
Rootl = 2.00
Root2 = -4.00
C program run Second Time
Input values of a, b, and c 1 2 3
discriminant = -8.000000
Roots are Imaginary