If the initial value of i is 2 What is the value of expression i++ + i++?
Solution:
It’s undefined. Both in C & in C++.
The standard says:
“If you read a variable twice in an expression where you also write it, the result is undefined.”
So you should never do that 🙂
Another example is:
arr[i] = i++;
More undefined behavior: In the below example also, the values passed to the function are not defined irrespective to the value of i.
fun(arr[i], i++);
Here, the result is undefined because the order of evaluation of function arguments is undefined