it is not passing testcases please help me in finding the error. here i am attaching my code
Quadratic equation problem
#include
#include
using namespace std;
int main()
{
int a,b,c,dis,x1,x2;
cin>>a>>b>>c;
dis=bb-4ac;
if(dis>0)
{
x1=(-b+sqrt(dis))/(2a);
x2=(-b-sqrt(dis))/(2a);
cout<<“real and distinct”;
cout<<“x1 is”<<x1<<endl;
cout<<"x2 is "<<x2<<endl;
}
else if(dis=0)
{
cout<<“real and equal”;
x1=-b/(2a);
cout<<“x1 =x2=”<<x1<<endl;
}
else
{
cout<<“real and imagianry”<<endl;
}
return 0;
}
Hey @ikshit9
#include<iostream>
#include<cmath>
using namespace std;
int main()
{ int a,b,c,dis,x1,x2;
cin>>a>>b>>c;
dis=b*b-4*a*c;
if(dis>0)
{
x1=(-b+sqrt(dis))/(2*a);
x2=(-b-sqrt(dis))/(2*a);
cout<<"Real and Distinct"<<endl; //updated
cout<<x2<<" ";
cout<<x1<<endl;
}
else if(dis==0)//updated
{
cout<<"Real and Equal";//UPDATED
x1=-b/2*a;
cout<<endl<<x1<<" "<<x1;//updated
}
else
{
cout<<"Imaginary";//updated
}
return 0;
}