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