Revising Quadratic Equations

#include
using namespace std;
int main()
{
int a,b,c,d,x1,x2,n;
cin>>a>>b>>c;
if(a>=-100 and a!=0)
{
if(b<=100 and c<=100)
{
d= bb-4(ac);
if(d>0)
{
cout<<“Real and distinct roots”<<endl;
for(n=0;n
n<=d;n++)
x1=(-b-n)/(2a);
x2=(-b+n)/(2
a);
cout<<x1<<" “<<x2;
}
else if(d==0)
{
cout<<“Real and equal roots”<<endl;
x1=x2=(-b)/(2*a);
cout<<x1<<” "<<x2;
}
else
cout<<“Roots are imaginary”;
}
else
cout<<“enter values of b and c within limit”;
}
else
cout<<“enter correct value of a”;
return 0;
}

this is my solution. the sample test case is passed successfully but while submitting it is showing wrong answer for the three test cases. I am not able to understand what am I missing in the solution.kindly help.

Hello @Shivank97,

The way you have shared your code is introducing many syntax errors to it.
Thus, share it using the online Coding Blocks IDE from the next time.
Steps:

  1. Paste your code there.
  2. Save your code.
  3. Share the URL generated.

Now, coming back to your question,

  1. You have to take care of the output format given in the code, else your test cases will fail.
    In your code, the following statements are not required by the question.

else
cout<<“enter values of b and c within limit”;
}
else
cout<<“enter correct value of a”;

  1. There is no requirement of the following conditional check:
    if(a>=-100 and a!=0){}
    if(b<=100 and c<=100){}

  2. There are few more problems in your code.

I have modified your code, please refer the code for better understanding:

Hope, this would help.
Give a like, if you are satisfied.

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.