Revising Quadratic Equations

#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

Hi @Chirag-Jain-1414278322030453
Just print the roots in increasing order

Hope it helps
Mark resolved if satisfied :slight_smile:

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.