eular project 2,not working

Alright, so i have used 2 variables in the for loop, and i expected it to add each other in the increment step(x+=y),instead its just incrementing by 1.

1
2
3
4
5
6
7
8
9
10
  #include<iostream>
using namespace std;
int main(){
int y=2;
for(int x=1;x<=13;x+=y){cout<<x<<endl;
for(y=2;y<=13;y+=x){cout<<y<<endl;}}
system("PAUSE");
return 0;
}
	
Change your code to:
1
2
3
4
5
6
7
8
  #include<iostream>
using namespace std;
int main(){
int y=2;
for(int x=1;x<=13;x+=y){cout<<"x:" << x<<endl;
for(y=2;y<=13;y+=x){cout<<"y: " <<y<<endl;}}
return 0;
}


That should clarify what exactly happens.
Of course !!!!thanks a lot man
Topic archived. No new replies allowed.