i use codeblocks for compiling.
The following is the code that i have written for solving quadratic equation.
Code:
#include<math.h>
main()
{
float a,b,c,discriminant,root1,root2;
printf("input values of a,b, and c\n");
scanf("%f %f %f",&a,&b,&c);
discriminant = (b*b - 4*a*c);
if (discriminant<0)
printf("\n\nROOTS ARE IMAGINARY\n");
else
{
root1=(-b+sqrt(discriminant))*1/(2.0*a);
root2=(-b-sqrt(discriminant))*1/(2.0*a);
printf("\n\nRoot1=%f\n\nRoot2=%f\n,root1,root2");
}
}
but when i enter the numbers 2,4,-16
it shows
root1=0.000000
root2=0.000000
i dont know what is wrong can anybody please help