What is the value of "val" after for's first loop?
A.
for (int val = 1; val <= 10; ++val)
{
cout << val <<endl; //I expected 2, but the result was 1.
}
B.
for (int val = 1; val <= 10; val++)//Result: 1
{
cout << val <<endl; //I expected 1, the result was 1.
}
Why got the same value?
I looked at the explanation, but do not quite understand why the results came that way:
" The postix increment operation occurs after the operand is evaluated.
In the prefix form, the increment takes place before the value is used in expression evaluation, so the value of the expression is different from the value of the operand.
See section 1.9.17 in the C++ standard for more information."
source: http://msdn2.microsoft.com/en-us/library/dy3d35h8(VS.80).aspx

Please give me the specific answer. Thanks!