/* Program to find the roots of Quadratic Equation */
#include<stdio.h>
#include<conio.h>
#include<math.h>
int main()
{
int a , b, c, d;
float x1, x2;
clrscr();
#include<conio.h>
#include<math.h>
int main()
{
int a , b, c, d;
float x1, x2;
clrscr();
printf("Enter the value of a, b, c:");
scanf("%d%d%d", &a, &b, &c);
d=(b*b)-(4*a*c);
if(d==0)
{
printf("\nRoots are real and equal");
x1= x2=(-b)/(2*a);
printf("\nRoots are: %f \t %f ", x1, x2);
}
else
{
if(d<0)
printf("\nRoots are imaginary");
else
{
x1=((-b)+sqrt(d))/(2*a);
x2=((-b)-sqrt(d))/(2*a);
printf("\nRoots are real");
printf("\nRoots are : %f \t %f", x1, x2);
}
}
getch( );
}
scanf("%d%d%d", &a, &b, &c);
d=(b*b)-(4*a*c);
if(d==0)
{
printf("\nRoots are real and equal");
x1= x2=(-b)/(2*a);
printf("\nRoots are: %f \t %f ", x1, x2);
}
else
{
if(d<0)
printf("\nRoots are imaginary");
else
{
x1=((-b)+sqrt(d))/(2*a);
x2=((-b)-sqrt(d))/(2*a);
printf("\nRoots are real");
printf("\nRoots are : %f \t %f", x1, x2);
}
}
getch( );
}