What is wrongg with the code? It is always failing in 1 test case!

#include
#include
using namespace std;

int main() {
int a,b,c;
float D,x1,x2;
cin>>a>>b>>c;

D=(b*b)-(4*a*c);

if(D==0){
    x1 = -b/(2*a);
    cout<<"real and equal"<<endl;
    cout<<x1<<" "<<x1;
}

else if(D>0){
    x1 = (-b + sqrt(D) )/(2*a);
    x2 = (-b - sqrt(D) )/(2*a);
    cout<<"real and distinct"<<endl;
    cout<<x1<<" "<<x2;
}

  else{
    cout<<"imaginary"<<endl;
}

return 0;
}

hey Himalaya, in case of real and distinct root, print x2 first than x1.

1 Like

Hey Himalaya, if your query is resolved. Please mark this doubt as resolved and rate me on the basis of your experience.
rating option will appear when to mark this doubt as resolved