// Compiler : Dev C++4.9.9.2
#include<stdio.h>
#include<math.h>
int main()
{
float a,b,c,d,root1,root2;
printf("A : ");
scanf("%f",&a);
printf("B : ");
scanf("%f",&b);
printf("C : ");
scanf("%f",&c);
d=b*b-4*a*c;
if(d<0)
{
printf("\n\nRoots Are Complex Number.");
printf("\n\nRoots Of Quadratic Equation Are : %.3f%+.3fi, %.3f%+.3fi",-b/(2*a),sqrt(-d)/(2*a),-b/(2*a),-sqrt(-d)/(2*a));
getch();
return 0;
}
else if(d==0)
{
printf("\n\nBoth Roots Are Equal.");
root1=-b/(2*a);
printf("\n\nRoot Of Quadratic Equation Is : %.3f",root1);
getch();
return 0;
}
else
{
printf("\n\nRoots Are Real Numbers.");
root1=(-b+sqrt(d))/(2*a);
root2=(-b-sqrt(d))/(2*a);
printf("\n\nRoots Of Quadratic Equation Are : %.3f, %.3f",root1,root2);
}
getch();
return 0;
}
Post a Comment