Revising quadratic eqn

Even though the code is executing correctly for all inputs, I am not being able to submit it. pls help!
my code:
#include
#include
using namespace std;

int main() {

float a, b, c, x1, x2, discriminant;
cout << "Enter coefficients a, b and c: "<<"\n";
cin >> a >> b >> c;
if(a==0)
{
    cout<<"this is not a quadratic equation!!"<<"\n";
}
else if(a!=0)
{
    discriminant = b*b - 4*a*c;
        if (discriminant > 0) {
        x1 = (-b - sqrt(discriminant)) / (2*a);
        x2 = (-b + sqrt(discriminant)) / (2*a);
        cout << "Roots are real and different." << endl;
        cout<<x1<<" "<<x2<< endl;
        }

        else if (discriminant == 0) {
        cout << "Roots are real and same." << endl;
        x1 = (-b + sqrt(discriminant)) / (2*a);
        cout <<x1<<" "<<x1<< endl;
        }

        else {
        cout<<"roots are imaginary!"<<"\n";
    }
}
return 0;

}

Hello @gayatri20,

Always share your code using online Coding Blocks IDE.
The way you have shared it may cause syntax errors.
STEPS:

  1. Paste your code on https://ide.codingblocks.com/
  2. Save your code there.
  3. Share the URL generated.

Now, coming back to your question:
Whenever you solve questions, please read the input and output formats carefully.
Example:
cout << “Enter coefficients a, b and c: “<<”\n”;
cout<<“this is not a quadratic equation!!”<<"\n";
cout << “Roots are real and different.” << endl;
cout << “Roots are real and same.” << endl;
cout<<“roots are imaginary!”<<"\n";
All the above mentioned statements are unnecessary and causing wrong output.

I have corrected your code:

NOTE:
If you have downloaded the test cases or unlocked the editorial then you won’t get any marks.
SUGGESTION:
You should only unlock these after scoring full marks for your submission.

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.