ok heres what i have. keep in mind that i only know really basic functions, as i have just started doing this -
Code:
#include <iostream.h>
#include <math.h>
#include <stdlib.h>
int main()
{
int a;
int b;
int c;
double x;
double x2;
double m;
double n;
double q;
double r;
m = -b + sqrt(b - 4*a*c);
n = 2*a;
q = -b - sqrt(b-4*a*c);
x = m/n;
x2 = q/n;
cout<<"Please enter a:";
cin>>a;
cout<<"Please enter b:";
cin>>b;
cout<<"Please enter c:";
cin>>c;
if ((b*b)-(4*a*c)<0)
{
cout<<"Answer contains non-real numbers";
}
else
{
cout<<"x = "<<x<<"or x = "<<x2<<" ....Please check for extranious answers....";
}
system ("pause");
return (0);
}
its supposed to do the quadratic formula { x = ( -b + root(b² - 4(a)(c)) / 2a } which solves for x when given standard form ( ax² + bx + c = 0 )
if that equation is kinda unreadable, here it is also:
http://www.sosmath.com/algebra/quadr...rmula/img9.gif
it might be an order of operations thing, but im not really sure..
thanks
-paul