#include<stdio.h>
#include<math.h>
int main ()
{
float a,b,c,P,D,i;
printf("\t The Quadratic Equation looks like this : (a)x*x + (b)x + c = 0\nYou will be entered the value of a,b and c");
printf("\nEnter the Values of a,b,c\n");
printf("Quadratic Equation is : a(x*x)+b(x)+c=0\n");
printf("Here 'a' is : Leading Coefficient of a Quadratic Equation OR coeff. of x*x\n");
printf("Here 'b' is : Coefficient of x\n");
printf("Here 'c' is : Absolute Constant\n");
printf("\n Enter the value of a : ");
scanf("%f",&a);
printf(" Enter the value of b : ");
scanf("%f",&b);
printf(" Enter the value of c : ");
scanf("%f",&c);
D=(b*b-4*a*c);
P=sqrt(D);
if (a==0)
{
printf("\n Warning ! For Quadratic Equation a>0 and a<0");
}
else
{
if (D<0)
{
printf("\n Roots are Imaginary\n");
printf("\n In the Complex Form (p+iq) and (p-iq)\n");
printf(" Where 'i' is iota: value is square root of -1\n-------\n");
i=sqrt(-D);
printf(" First Root : %.2f + %.2f i\n",(-b)/(2*a),i/(2*a));
printf(" Second Root: %.2f - %.2f i\n-------\n",(-b)/(2*a),i/(2*a));
}
else if (D==0)
{
printf(" \n Roots are equal , perfect Square\n");
printf(" \n First Root : %.2f\n",((-b)+P)/(2*a));
printf(" Second Root : %.2f\n",((-b)-P)/(2*a));
}
else if (D>0)
{
printf(" \n Roots are Real and Different\n");
printf(" \n First Root : %.2f \n",((-b)+P)/(2*a));
printf(" Second Root : %.2f \n---------\n",((-b)-P)/(2*a));
printf(" Discriminant : %.2f \n---------\n",D);
printf(" Sum Of roots : %.2f \n", -b/a);
printf(" Product of roots : %.2f \n", c/a);
printf(" Difference of roots : %.2f \n", P/a);
}
}
return 0;
}