input (1, -8, 16) output: real and same: 4,4
code:
#include
#include
using namespace std;
int main()
{
float a, b, c, x, y, D;
cin>>a>>b>>c;
if((a>=-100)&&(a<=100))
{ if((b>=-100)&&(b<=100))
{ if((c>=-100)&&(c<=100))
{
D=(float)((b*b)-(4*a*c));
if (D>0)
{
x=(float)((-b - sqrt(D))/(2*a));
y=(float)((-b + sqrt(D))/(2*a));
cout<<"Real and Distinct"<<endl;
cout<<x<<" "<<y;
}
else if(D==0)
{
x=(float)((-b)/(2*a));
y=x;
cout<<"Real and Same"<<endl;
cout<<x<<" "<<y;
}
else
{
cout<<"imaginary";
}
}}}
return 0;
}
(however when i run the code and enter input got correct answer)