my output is coming right but testcases are wrong howto submit the code
Revising quadratic equation
my code is #include using namespace std; int squareroot(int x) { if (x == 0 || x == 1) return x; int i = 1, result = 1; while (result <= x) { i++; result = i * i; } return i - 1; } int main() { int a,b,c,d,e,r1,r2; cin>>a>>b>>c; d=(bb)-(4ac); e=squareroot(d); if(d>0) { cout<<"roots are real and distinct "<<endl; r1=((-b+e)/(2a)); r2=((-b-e)/(2a)); cout<<r1<<" "<<r2<<endl; } else if(d<0) { cout<<"roots are imaginary "<<endl; } else { cout<<"roots are real and equal "<<endl; r1=r2=(-b/(2a)); cout<<r1<<" "<<r2<<endl; } return 0; }
@madhur Try printing the roots in increasing order.Also check the output format is same as given in the sample output. If still tests cases does not pass, then please copy the question/problem statement with and paste it here, I will check.
Please check one test case is failing on hackerblock problem
https://hack.codingblocks.com/app/contests/1039/p/50