Be sure to #include<cmath> and call the pow() and sqrt() functions when making your math calculations. Also note, the coefficients a b and c are to be declared as a double, as well as your two solutions for X.
this is what i did so far:
Expand|Select|Wrap|Line Numbers
- #include <cmath>
- #include <iostream>
- using namespace std;
- int main ()
- {
- int a;
- int b;
- int c;
- int x;
- double posx, negx; //declare positive x and negative y
- cout<<"Enter the value of a: ";
- cin>>a;
- cout<<"Enter the value of b: ";
- cin>>b;
- cout<<"Enter the value of c: ";
- cin>>c;
- int check;
- check=(b*b)-(4*a*c);
- if (check>0)
- {
- posx=(-b+sqrt(check))/2*a;
- negx=(-b-sqrt(check))/2*a;
- system ("pause");
- return 0;
- }
- }