Revising Quadratic Equations problem

3rd testcase is not passing. Almost all the conditions are taken care of through the code.

hi shatannun
share your code

#include
#include
using namespace std;
int main() {
double a,b,c,discriminant,x,y;
cin>>a>>b>>c;
if(a!=0)
{
discriminant = (bb) - (4ac);
if(discriminant<0)
cout<<“Imaginary\n”;
else
{
x = (-b+sqrt(discriminant))/(2
a);
y = (-b-sqrt(discriminant))/(2*a);
if(x!=y)
{
cout<<“Real and Distinct\n”;
cout<<x<<" “<<y<<endl;
}
else
{
cout<<“Real and Equal\n”;
cout<<x<<” "<<x<<endl;
}

    }    
}
else if(b!=0)
{
    x = (-c)/b;
    cout<<"Real and Equal\n";
    cout<<x<<" "<<x<<endl;
}
else
{
    cout<<"Imaginary\n";
}
return 0;

}

when the root the real and distinct print the smaller root first

1 Like

Thankyou!
It worked.

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.