#include <iostream>
#include <cmath>
using namespace std;
int main()
{
double x, y;
for(x=-2,x<=4,x=x+0.5) {
y= (4*(x*x*x)-12*(x*x)-9*x+27)/
(sqrt(5*(x*x)+2)+3*abs(x-2.5));
cout<<"x= "<<x <<" y="<< y;
if (y>0)
cout<< "y is positive";
if (y==0)
cout<< "y is zero";
if (y<0)
cout<< "y is negative";
cout<< endl;
}
cout<< endl; << "My first program is complete" <<endl;
return 0;
}
this is my code and i keep getting three error messages:
expected ';' before ')' token in line 9
expected primary-expression before '<<' token in line 21
expected ')' before ';' token in line 21.
what am i doing wrong? and how does everyone paste what they type in, in code blocks. thanks
#include <iostream>
#include <cmath>
usingnamespace std;
int main()
{
double x;
double y;
for(x=-2;x<=4;x=x+0.5)
{
y= (4*(x*x*x)-12*(x*x)-9*x+27);
(sqrt(5*(x*x)+2)+3*abs(x-2.5));
cout<<"x= "<<x <<" y="<< y;
if (y>0)
{
cout<< "y is positive";
}
if (y==0)
{
cout<< "y is zero";
}
if (y<0)
{
cout<< "y is negative";
cout<< endl;
}
}
cout<< endl << "My first program is complete" <<endl;
cin.get();
}