I was asked in a job interview what would the following code in C++ would output to screen:
int i = 3;
cout << (++i + i++ - ++i + i++);
return 0;
In my computer it outputs 9, but why? Is this undefined?
I was asked in a job interview what would the following code in C++ would output to screen:
int i = 3;
cout << (++i + i++ - ++i + i++);
return 0;
In my computer it outputs 9, but why? Is this undefined?
 
    
    yes this is system dependent. Behavior not defined because of that.
Here which will be computed first ++i or i++ is different. This is unspecified.
