![C program to calculate roots of quadratic equation ax^2+bx+c=0 C program to calculate roots of quadratic equation ax^2+bx+c=0](https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh5CKrftoyIpEdDyqjXO8GXhBAAohjL1onuhCrfNbr-qYUsR4W0yDwRUgG1s8lw4Rl5-L2S9lRZZWrlSnxWFZb1y6dkfekS8LAKb6td1acMIJzuFnSdazQIbNIopkTMzHBEGnzl16TwTe3G/s1600/C+program+to+calculate+roots+of+quadratic+equation+ax%5E2+bx+c=0.jpg)
#include<stdio.h>
#include<conio.h>
#include<math.h>
void main()
{
float root1,root2,a,b,c,d;
clrscr();
printf("Quadratic Equation is ax^2=bx+c=0");
printf("
Enter values of a,b and c:");
scanf("%f%f%f",&a,&b,&c);
d=(b*b)-(4*a*c);
if(d>0)
{
printf("
Two real and distinct roots");
root1=(-b+sqrt(d))/(2*a);
root2=(-b-sqrt(d))/(2*a);
printf("
Roots are %f and %f",root1,root2);
}
else
if(d==0)
{
printf("
Two real and equal roots");
root1=root2=-b/(2*a);
printf("
Roots are %f and %f",root1,root2);
}
else
printf("
Roots are COMPLEX and IMAGINARY....!!!");
getch();
}