help me with this one

#include <iostream>
using namespace std;
int main();
{
int x;
for (x=24; x<=504; x+60;);

cout<<"Starting at 1625 to 2026"<<x<<endl;


return 0;
}


is this correct?
Z:\Cruz_Exercises\LE5_Cruz.cpp(6) : warning C4552: '+' : operator has no effect; expected operator with side-effect
Z:\Cruz_Exercises\LE5_Cruz.cpp(6) : error C2059: syntax error : ';'
where is the error
I don't think you are allowed to have another semicolon after the x+60 in the for loop. Also, as the warning notes, that for loop will be infinite because x+60 does not change the value of x.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
#include <iostream>
using namespace std;

int main(){
	int x;
	// x gets initialized to 24, loop thorugh until less than or equal to
	// 504, x needs to be incremented by 60, the following syntax is the 
	// same as x = x + 60
	for (x=24; x <= 504; x+=60){ // you should use these brackets 
		cout<<"Starting at 1625 to 2026"<<x<<endl;// for standard format
	}// but you don't have to for one line of code, but it's proper
	
		return 0;
	}


read my comments and it will begin to make more sense
Topic archived. No new replies allowed.