quadratic formula in c

This is a discussion on quadratic formula in c within the C Programming forums, part of the General Programming Boards category; so i need to find the real roots after entering an a b and c for the quadratic formula....i basically ...

  1. #1
    Registered User
    Join Date
    Feb 2009
    Posts
    36

    quadratic formula in c

    so i need to find the real roots after entering an a b and c for the quadratic formula....i basically have it except when i type in lets say 3 2 1 it says -1.#ind0....i have read that this is because there is some kind of math error...i dont know if i necessary want to post my code because i know my classmates use this website...would it be valid to say

    [code]

    if ( a > b && a > c)
    printf("there are no real roots.\n")

    [\code]

    this might be more of a math question but i thought i would take a shot

  2. #2
    Registered User
    Join Date
    Feb 2009
    Posts
    36
    nevermind haha i got it

  3. #3
    Ex scientia vera
    Join Date
    Sep 2007
    Posts
    478
    For those who might look at this question and wonder about the answer:

    Given a quadratic equation of the form 0 = ax^2 + bx + c, you must first look at the discriminant, d = b^2 - 4ac, before you go ahead and solve it.

    If d > 0, there are two real roots:
    x1 = (-b + sqrt(d))/2a
    x2 = (-b - sqrt8d))/2a

    If d = 0, there is one real root:
    x = -b/2a

    And if d < 0, there are no real roots, but 2 complex roots:
    x1 = -b/2a + i * sqrt(-d)/2a)
    x2 = -b/2a - i * sqrt(-d)/2a)
    "What's up, Doc?"
    "'Up' is a relative concept. It has no intrinsic value."

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Need help with quadratic formula functions
    By orikon in forum C++ Programming
    Replies: 10
    Last Post: 10-15-2005, 05:49 PM
  2. Help on quadratic formula DOS program
    By blankstare77 in forum C++ Programming
    Replies: 2
    Last Post: 08-23-2005, 09:57 PM
  3. how to change char to formula
    By kosong in forum C Programming
    Replies: 2
    Last Post: 06-09-2003, 05:31 AM
  4. Formula string conversion
    By Gr3g in forum C++ Programming
    Replies: 2
    Last Post: 04-12-2002, 09:28 PM
  5. Quadratic Equation Program
    By Ambizzy in forum C Programming
    Replies: 4
    Last Post: 02-19-2002, 09:21 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21