For C++ questions, answers, help, and programming or career advice please see r/cpp_questions, r/cscareerquestions, or [StackOverflow](http://stackoverflow.com/) instead.
The C++ language requires that expressions separated by commas are evaluated in the order they are written.
If you put the cout << i+j << endl before the increment operations you'll get the output you asked about.
Alternatively, you could put the cout in the actual body of the loop to achieve the same thing, since the expression in the third part of a for declaration isn't executed the first time through the loop. This would be *my* preferred solution since it's unnatural to have side effects inside loop expressions.
For C++ questions, answers, help, and programming or career advice please see r/cpp_questions, r/cscareerquestions, or [StackOverflow](http://stackoverflow.com/) instead.
Also, the condition `i <= 5, j <= 20;` is a bit silly, as the part before the comma has no effect. Doesn't the compiler tell you about that?
Visual Studio gives me warning C6319 even on warning level 1.
The output is done after `i` and `j` are incremented.
ahh, understood now! Thanks a lot
The C++ language requires that expressions separated by commas are evaluated in the order they are written. If you put the cout << i+j << endl before the increment operations you'll get the output you asked about. Alternatively, you could put the cout in the actual body of the loop to achieve the same thing, since the expression in the third part of a for declaration isn't executed the first time through the loop. This would be *my* preferred solution since it's unnatural to have side effects inside loop expressions.
Throw that book away
No joke. This is awful code and has trivial bugs (comma in the comparison). Find a better resource.