[Solved] Solving ax^2+bx+c=0 equation using C [closed]


The problem is in your first if statement:

if (d=0)

This is not comparing d to 0, but is assigning 0 to d. This expression then takes on the value of the assignment, i.e. 0, which evaluates to false. That in turn causes else if (d>0) to evaluate to false, bringing you to the else condition at the end.

Change the assignment operator to a comparison:

if (d==0)

If you compile with -Wall -Wextra, it will warn you of this:

warning: suggest parentheses around assignment used as truth value

1

solved Solving ax^2+bx+c=0 equation using C [closed]