Regarding quadratic problem

sir my code is not passing all the test cases ,could you please tell why
the code which i have written is:
#include
#include<math.h>
using namespace std;
int main()
{
int a,b,c;
float root1=0,root2=0,d=0;
cin>>a>>b>>c;
d=sqrt(pow(b,2)-4*(ac));
root1=(-b+d)/2
a;
root2=(-b-d)/2*a;
if(d>0)
{
cout<<“Real and distinct”<<endl;
if(root1>root2)
{
cout<<root2<<" “;
cout<<root1;
}
else
{
cout<<root1;
cout<<root2;
}
}
else if(d=0)
{
cout<<” real and equal"<<endl;
cout<<root1;

}
else
{
	cout<<"Roots are imaginary"<<endl;
}
return 0;

}

Hi @Megha2468
Your code is not passing all test cases because of following reasons :

  1. For real and equal root you need to print both the roots. And in if condition it should be d==0
  2. For imaginary you need to print Imaginary
  3. For real and distinct roots in the else case there should be gap between root1 and root2

Here is your corrected code :

If your doubt is clear then mark it as resolved.