#include <stdio.h>
#include <math.h>
int main ()
{
int a,b,c,D;
float root1,root2;
printf("the coefficients (a,b,c)\n");
scanf("%d",&a);
scanf("%d",&b);
scanf("%d",&c);
D=b*b-4*a*c;
if(D>0)
{
printf("the roots are real\n");
root1=(-b+(sqrt(D)))/2*a;
root2=(-b-(sqrt(D)))/2*a;
printf("the value of the first root is %f\n",root1);
printf("the value of the second root is %f\n",root2);
}
else if(D==0)
{
printf("the roots are equal\n");
root1=(-b/2*a);
root2=(-b/2*a);
printf("the value of the first root is %f\n",root1);
printf("the value of the second root is %f\n",root2);
}
else
{
printf("the roots are imaginary\n");
}
return 0;
}
To embed this project on your website, copy the following code and paste it into your website's HTML: