Please explain output of this program.
#include<stdio.h>
int main()
{
int x=0;
x ^= x || x++ || ++x || x++;
printf("\n%d",x);
}
O/p is 3 (http://codepad.org/X49j0etz)
According to me output should be 2.
as || is a sequence point as far as i remember.
so expression becomes.
x ^= 0 || 0 || 2 || 2;
so after evaluation of this expression(x || x++ || ++x || x++;) x becomes 3
x = 3 ^ 1
so x becomes 2;