quadratic equation help

#include <stdio.h>
#include <math.h>

void quadraticplus(double, double, double);
double i, o, p, ans4;

main()
{
printf("Enter the three variables\nvariable a = ");
scanf("%lf", &i);
printf("variable b = ");
scanf("%lf", &o);
printf("variable c = ");
scanf("%lf", &p);
quadraticplus(i,o,p);
getch();
}

void quadraticplus(double a, double b, double c)
{
ans4=(-b+sqrt(b*b-(4*a*c)))/(2*a);
printf("\n%lf", ans4);
return;
}

i also had the same user define function for the neagtive side of the quad equation. (void quadraticneg....)

i try running the program but my answers return as -1.#IND00 for both plus and negative sides. please help
Last edited on
b^2-4ac has to be >0. Did you check that?
oh ok it doesnt solve imaginary numbers. i put in an example i found online and it works perfectly! thanks.
If you use C++ you can actually work with complex numbers:
http://www.cplusplus.com/reference/std/complex/
Topic archived. No new replies allowed.