hi
i m a student nd need to write a program to input coefficients of a quadratic equation and output its roots .
There is some problem in this , i tried several variations but it is not working.
Please check and let me know what's wrong and how to fix it...
#include <stdio.h>
#include <conio.h>
#include <math.h>
main()
{
float a,b,c,d,r1,r2;
printf("Enter the coefficients ...");
scanf("%f %f %f",&a,&b,&c);
d=((b*b)-(4*a*c));
if (!d<0)
{
if (d=0)
{
r1=((-b)/(2*a));
r2=r1;
}
else
// if (d>0)
{
r1=((-b+sqrt(d))/(2*a));
r2=((-b-sqrt(d))/(2*a));
}
}
printf("%f %f",r1,r2);
getch();
return 0;
}