I don't understand the output of the following program:
#include<stdio.h>
int main()
{
int i=-3, j=2, k=0, m;
m = ++i || ++j && ++k;
printf("%d %d %d %d\n", i, j, k, m);
return 0;
}
The output is -2 2 0 1
instead of -2 3 1 1
, implying that ++i
was evaluated (and caused the ||
operator to short-circuit its right hand side) before the expression ++j && ++k
which appears to contradict the fact that the &&
operator has higher precedence than ||
.
Would someone explain why?