0
Why is this equivalent to 5?
3 Respostas
+ 5
The for loop doesn't do anything. Note the empty curly brackets. It's an empty statement, just like for(int i = 0;i<7;++i); // <= note the semicolon at the end. Also, the variable i in the for loop is not the same variable that is used outside of the loop, because it was declared in the for loop. So the outer variable i isn't affected in any way.
If you change it like this:
for(i=0; i<7; ++i) {}
it will actually affect the outer variable i.
+ 4
5, because loop is not for i
+ 1
thanks