Getting only 2 testcases right

In the revising quadratic equation question from fudamental challenges i am getting only two testcases correct please tell me what is wrong in the code

Hello @amarshmalik0,

  1. You have not shared your entire code.

  2. The way you have shared your code is introducing many syntax errors to it.
    Please, send it using Online Coding Blocks IDE.
    Steps:
    2.1. Paste it on IDE.
    2.2. Save it there.
    2.3. Share the URL generated.

Here is the link

I have also uploaded a screenshot as well

Hello @amarshmalik0,

  1. Your code is producing wrong output.
    It is due to the way you are using the formula.
    It is due to the error introduced due to rounding off to float.
    Example:
    1 -11 28
    Required Output:
    Real and Distinct
    4 7
    Your Output:
    Real and Distinct
    6.5 3.5

  2. While calculating f, you are doing the sqrt of 2*a also.

3… Also the order of printing the roots does not match with that of the question

I have modified your code:

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

1 Like