Can someone help me with this code??

#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
Last edited on
closed account (ozUkoG1T)
the code is :
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#include <iostream>
#include <cmath>
using namespace 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();

}
Last edited on
thank you very much. i fixed the mistakes but now its giving me a different error. now it says: cant open output file for writing.
closed account (ozUkoG1T)
Try rebuild it
Topic archived. No new replies allowed.