Do we have to write the code using if else blocks or something else? Can you review my code:
float a=0,b=0,c=0,r1=0,r2=0;
cout<<"Enter coefficents a[>=-100],b and c[<=100] respectively): ";
cin>>a>>b>>c;
float d;
d=(b*b)-(4*a*c);
float d1=sqrtf(d);
if(d<0){
cout<<“The roots of the given equation are imaginary.”<<endl;
}
else if(d=0){
cout<<"The roots are real and equal."<<endl;
r1=r2=(-b)/2*a;
cout<<"The roots are: "<<r1<<' '<<r2;
}
else if(d>0){
cout<<"The roots are real and distinct."<<endl;
r1=((-b)-d1)/(2*a);
r2=((-b)+d1)/(2*a);
cout<<"The roots are: "<<r1<<' '<<r2;
what is the problem in this? I am not able to pass 2 test cases.