// Compiler : Dev-C++ 4.9.9.2
#include<stdio.h>
#include<math.h>
int main()
{
int a,b,c;
float disc,r1,r2;
for(;;)
{
printf("\nEnter Non Zero Co-Efficients...\n\n\nA : ");
scanf("%d",&a);
printf("\n\nB : ");
scanf("%d",&b);
printf("\n\nC : ");
scanf("%d",&c);
if((a==0) || (b==0) || (c==0))
printf("\n\nPlease Enter Non Zero Co-Efficients...");
else
{
disc=((b*b)-(4*a*c));
if(disc>0)
{
r1=(-b-(sqrt(disc)))/(2.0*a);
r2=(-b+(sqrt(disc)))/(2.0*a);
printf("\n\n\nRoots Are Real...\n\nRoots Are : %f And %f",r1,r2);
}
else if(disc<0)
{
r1=-b/(2.0*a);
printf("\n\n\nRoots Are Imaginary...\n\nFirst Root : %lf +%lfi\n\nSecond Root : %lf -%lfi",r1,sqrt(-disc)/(2.0*a),r1,sqrt(-disc)/(2.0*a));
}
else
{
r1=-b/(2.0*a);
printf("\n\n\nRoots Are Equal...\n\nRoots Are : %f and %f",r1,r1);
}
getch();
return 0;
}
}
}
Post a Comment