fakespike 0 Junior Poster in Training

well i made this little program to help me check my algebra home work it was soppose to be a simple thing so it is badly coded and rushed but something has happened that i dont understand. i have spotted the problem but dont know why its doing this.
for values a=1 b=-2 c=-3
it works fine i get the right answer
but for values a=1 b=8 c=10 ths anwser should be -1.55 or -6.45.
problem is it does the wrong if statement but why?.
this program is for the algebra equation (-b(+)(-)root(b^2-4ac)) /2

#include <iostream.h>
#include <conio.h>
#include <math.h>
double a;
void equation();
void main()
{
    cout<<"*******************************\n"
        <<"****    press -1 to exit   ****\n"
        <<"*******************************\n";

    while(a>=0)
    equation();
    getch();
}
void equation()
{
    double b,c,ac,e,z,f,g,j,divider;
    cout << "please input a value for a: ";
    cin  >> a;
    if(a!=-1)
    {
    cout << "please input a value for b: ";
    cin  >> b;
    cout << "please input a value for c: ";
    cin  >> c;
    ac = -4*a*c; 

************************
    if (ac <= 0)            *       problem here 
    e = pow(b,2)-ac;    *
    else                        *
    e = pow(b,2)+ac;   *
************************
    divider = 2*a; 
    z = sqrt(e);

    f= (-(b)+z)/divider;    
    g=(-(b)-z)/divider;
    cout << "answer = " << g << " Or " << f;
    cout<< "\n";
    cout<< "\n";
    }
}

plz help

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.