• 02-07-2009
cakestler
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
• 02-07-2009
cakestler
nevermind haha i got it
• 02-08-2009
IceDane
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)