#include
#include
using namespace std;
int main() {
int a,b,c,d;
float e,r1,r2;
cin>>a>>b>>c;
if (a==0){
cout<<"Real and Distinct"<<endl;
d = -c/b;
cout<<d<<" "<<d;
}
else{
d = ((b*b)-(4*a*c));
if (d>0){
cout<<"Real and Distinct"<<endl;
e = sqrt(d);
r1 = (-b+e)/(2*a);
r2 = (-b-e)/(2*a);
cout<<r1<<" "<<r2;
}
if (d==0){
cout<<"Real and Equal"<<endl;
r1 = (-b)/(2*a);
r2 = r1;
cout<<r1<<" "<<r2;
}
if (d<0){
cout<<"Imaginary";
}
}
return 0;
}
Why does this code fails for a=1 , b = -8, c = 16?
According to the code, it should print real and equal followed by 4 4, but this test case fails
