In C language, Why does n++ execute faster than n=n+1?
n++
n=n+1
(int n=...; n++;) (int n=...; n=n+1;)
Our instructor asked
The compiler will optimize n + 1 into nothingness.
n + 1
Do you mean n = n + 1?
n = n + 1
If so, they will compile to identical assembly. (Assuming that optimizations are on and that they're statements, not expressions)