Quadratic Problem

The Question is : Given coefficients of a quadratic equation , you need to print the nature of the roots (Link: https://hack.codingblocks.com/contests/c/587/50)

One of the test cases is failing. My code is:

#include
#include
using namespace std;

int main() {
long a=0,b=0,c=0;
long disc=0;
long root1=0,root2=0;
cin>>a>>b>>c;
disc = (bb)-(4ac);
if(disc==0)
{
cout<<“Real and Equal”<<endl;
root1= (-b)/(2
a);
cout<<root1<<" “<<root2;
}
else if(disc>0)
{
root1 = (-b + sqrt(disc))/(2a);
root2 = (-b - sqrt(disc))/(2
a);
cout<<“Real and Distinct”<<endl;
cout<<root2<<” "<<root1;
}

else{
    cout<<"Imaginary";   
}

return 0;
}
Please point out the mistake in the code.
Thanks

please share code on IDE. It is having lots of compilation errors.

Hey Srindhi, check your code line:11 if condition block

if(disc==0)
{
cout<<"Real and Equal"<<endl;
root1= (-b)/(2*a);
cout<<root1<<" "<<root2;
}

in this you are calculating root1 only but prints root1 and root2, here root2 will always be 0 as you haven’t calculated it. So, as both the roots are equal in this condition update your print statement like this
cout<<root1<<" "<<root1;

Hi @sanjeetboora thank you, the issue has been solved.