Quadratic Equations, given sample test case gives wrong output

https://ide.codingblocks.com/s/70935

HI Ananya there are a few mistakes in your code.

Firstly, use sqrt function instead of pow.

Secondly, you are not evaluating roots correctly.
When the 2 roots are real, then let it be:

x1 = - b/(2*a);

when they are distinct you have to print smaller one first and then the larger so let it be:

x1= -(b+sqrt(d)) / (2a);
x2= -(b-sqrt(d)) / (2
a);
// Note here x1 < x2 always.

Make these changes.
Your code will pass all the testcases now :slight_smile: .

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.