#include<iostream.h>
#include<conio.h>
#include<math.h>
void main()
{
char choice=1;
int a, b, c, d, x1, x2, loopy=0;
do
{
clrscr();
while (loopy!=80)
{
cout<<"-";
loopy++;
}
cout<<"\nQuadratic Equation Solver."
<<"\n";
while (loopy!=0)
{
cout<<"-";
loopy--;
}
cout<<"\n"
<<"Enter the values of a, b and c\n";
cin>>a>>b>>c;
cout<<"\n";
while (loopy!=80)
{
cout<<"-";
loopy++;
}
cout<<"\n";
d=(b*b)-(4*a*c);
if (d<0)
{
d=(-1)*d;
x1=(-b-sqrt(d)/(2*a));
x2=(-b+sqrt(d)/(2*a));
cout<<"The Roots are not real.\n";
if (x1==0)
{
cout<<"x1="<<x1<<",x2="<<x2<<"i";
}
else if (x2==0)
{
cout<<"x1="<<x1<<"i,x2="<<x2;
}
else if (x1==x2)
{
cout<<"x1=x2="<<x1<<"i";
}
else
{
cout<<"x1="<<x1<<"i,x2="<<x2<<"i";
}
}
else
{
x1=(-b-sqrt(d)/(2*a));
x2=(-b+sqrt(d)/(2*a));
cout<<"The Roots are real.\n";
if (x1==x2)
{
cout<<"x1=x2="<<x1;
}
else
{
cout<<"x1="<<x1<<",x2="<<x2;
}
}
cout<<"\n\n";
while (loopy!=0)
{
cout<<"-";
loopy--;
}
cout<<"\nPress Y to solve another equation or press any key to exit.";
cin>>choice;
}
while (choice=='Y' || choice=='y');
}