Program |
void main()
{
float a,b,c,r1,r2,displacement;
printf("\n Enter a,b,c Values Quadratic Equation:\n");
scanf("%f%f%f",&a,&b,&c);
displacement=b*b-4*a*c;
if(displacement>0)
{
r1=-b+sqrt(displacement)/2*a;
r2=-b-sqrt(displacement)/2*a;
printf("\n*****ROOTS ARE REAL & UNEQUAL*****\n");
printf("\n r1=%f\n r2=%f",r1,r2);
}
else if (displacement==0)
{
r1=r2=-b/2*a;
printf("\n*****Roots are EQUAL*****\n");
printf("\n r1=%f\n r2=%f",r1,r2);
}
else
printf("\n Imaginary Roots.");
}
|