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)/(2a);
cout<<root1<<" “<<root2;
}
else if(disc>0)
{
root1 = (-b + sqrt(disc))/(2a);
root2 = (-b - sqrt(disc))/(2a);
cout<<“Real and Distinct”<<endl;
cout<<root2<<” "<<root1;
}
else{
cout<<"Imaginary";
}
return 0;
}
Please point out the mistake in the code.
Thanks