Display the root of quadratic equation 

#include<stdio.h>
#include<conio.h>
#include<math.h>     //(It display various mathematical function)
void main()
{
int a,b,c;
float d,r1,r2;
printf("Enter the input for a,b,c:");
scanf("%d%d%d",a,b,c);
d=sqrt((b*b)-4(a*c));
if(d>0)
{
r1=-b+d/(2*a);
r2=-b-d/(2*a);
printf("The roots are: %3f%3f",r1,r2);
}
else                        //(Using ladder if-else)
{
0if(d==0)
{
r1=r2=-b/2*a;
printf("The roots are: %3f%3f",r1,r2);
}
else
{
printf("Imaginary roots");
}
}
getch();
}

OUTPUT:
Enter the input for a,b,c:1
2
1
The roots are:
-1.000000 -1.000000

Translate »