HelpPleaseHelp

Can you please mail me a subroutine that can solve a quadratic equation in the form



ax^2+bx+c=0






Comments

  • : Can you please mail me a subroutine that can solve a quadratic equation in the form

    :

    : ax^2+bx+c=0

    :

    :

    :



    here's how to solve a quadratic equation.

    i won't write the code for you, sorry :)



    d = b*b - 4*a*c



    x1 = (-b + sqrt(d)) / (2*a)

    x2 = (-b - sqrt(d)) / (2*a)



    if d is negative, then there's no solution for the equation, since the squareroot of negative numbers is not defined. in this case, you shouldn't try to calculate the squareroot of

    d, coz this will give you an error.



    if d is 0, then x1=x2 (kinda logic, isn't it ?)




Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories