Maynza
Formerly DontdroptheSOAD
Wrong answer.
I know this is simple, but I am teaching myself and i am trying to figure out why I am getting the wrong answer.
I think it is probably my order of operations.
I know this is simple, but I am teaching myself and i am trying to figure out why I am getting the wrong answer.
I think it is probably my order of operations.
Code:
#include <iostream>
#include <cmath>
using namespace std;
int main()
{
cout<<"The Quadratic Formula is represented as..."<<endl;
cout<<"-b+sqrt(b^2-4ac)/2a \n& \n-b-sqrt(b^2-4ac)/2a"<<endl;
cout<<"Enter the value of your polynomials."<<endl;
double a, b, c, x1, x2, q;
cout<<"A=";
cin>>a;
cout<<"\nB=";
cin>>b;
cout<<"\nC=";
cin>>c;
x1 = (-b+sqrt((b*b)-4*a*c))/2*a;
cout<<"X="<<x1;
cin>>q;
return 0;
}