+ 1
For loop
I tried putting a semicolon after a for loop with no body and it WORKS! here is the structure: for(int i=1;i<=5;i++,cout<<i<<endl); My question is WHY??
3 odpowiedzi
+ 7
Because a null statement is legal and there are times you want to make use of it. I would have reversed your expressions to output the numbers 1 to 5 instead of 2 to 6.
+ 3
got it, Thanks.
+ 1
Technically the increment part is part of the body. The i++ is executed at the end of the code you have inside the body.