#include<iostream.h>
#include<conio.h>
#include<math.h>
int main()
{
float a, b, c, r1, r2, d; // r1 and r2 are the roots
clrscr();
cout<<"Enter three numbers of equation ax2 + bx + c"<<endl;
cin>>a>>b>>c;
if (a==0)
cout<<endl<<"ERROR : Value of a should not be zero ";
else
{
d = b*b - 4*a*c ;
if(d > 0)
{
r1 = (-b+sqrt(d)) / (2*a);
r2 = (-b-sqrt (d)) / (2*a);
cout<<"Root are real and unequal "<<endl;
cout<<"Root1 = "<<r1<<endl;
cout<<"Root2 = "<<r2<<endl;
}
else if(d == 0)
{
r1 = - b /(2*a);
cout<<"Roots are real and equal"<<endl;
cout<<"Root1 = "<<r1<<endl;
cout<<"Root2 = "<<r1 ;
}
else
cout<<"Roots are complex and imaginary: "<<endl;
}
getch();
return 0;
}