1. You don't need to actually use complex numbers, you just need to know how they work and be clever with some radical simplification.

x=(-b +- sqr (b^2-4ac))/2a
i is the square root of -1. The part of the quadratic equation that could make complex numbers necessary is (sqr(b^2-4ac)). If (b^2-4ac) < 0 then you're going to need some complex numbers. For the example I'm about to give, let a=8, b=0, and c=2.

b^2-4ac
0^2-4(8)(2)
-64
At this point, we're trying to find the square root of -64.
sqr(-64)==sqr(-1*64)==sqr(-1)*sqr(64)==8*sqr(-1)=8i

In your code, if you just take the absolute value of b^2-4ac, take the square root of that, and slap an i after it (if b^2-4ac evaluates to <0) you'll be fine. Then, just stick that number into the quadratic formula...to finish it off, we have this:

x=(-b +- sqr (b^2-4ac))/2a
x=(-0+-8i)/(2*8)
x=(+-8i)/16
x=8i/16 or -8i/16
x=.5i or -.5i

See, never needed to program anything with complex numbers.

2. First of all, I'd like to say that the solution proposed by Blackrat is IMO the best for your problem. Secondly, there is a complex number class in the standard header files. I believe it's complex.h, but I may be wrong. If you can't find that library or have trouble using it, write your own class for complex numbers. I did that for a class once. Not difficult at all if you know how to work with complex numbers. The only data members you need are double a, b;

Hmmm, I never know how to end these posts. Umm, good luck!

3. Originally posted by Gil22
alright i think i actually need to use complex numbers......is therea way to declare these?
Yeah, include complex and declare a std::complex. A lot of what you will need has already been implemented for you.

4. an easier way to find ou if a number is imaginary is to find out if the equation under the radical is negative. If so then output an i after the output of the answer. If not then just evaluate it regullarly. A little bit of the code would look like this:
Code:
float determinant;
float root;

determinant = b*b - (4*a*c);

if(determinant < 0)
{
determinant = determinant * -1;
root1 =  (b + Sqrt(determinant) )/ 2;
root 2 = (b - Sqrt(determinant) )/ 2;

cout << "The answers are: " << root1 << "i, " << root2 << "i." << endl;
}

else
{
root1 =  (b + Sqrt(determinant) )/ 2;
root 2 = (b - Sqrt(determinant) )/ 2;

cout << "The answers are: " << root1 << ", " << root2 << endl;
}
There you go. Hope it helps you out.

-Bill