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;
}