int j = 3;
for (int i = 0; i < 3; i++)
{
j=j++;
}
cout<<j<<endl;
My approach - Incase of post-increment value is assigned first to the variable then incremented so the following transitions should happen.
- i=0 j=3 (3 increments to 4)
- i=1 j=4 (4 increments to 5)
- i=2 j=5 (5 increments to 6)
Now the expected output should be 6 but it's 3, Why is my approach wrong? Thankyou