retagged by
408 views
1 votes
1 votes

what will be the output of the following piece of code?
 

void add()

{
    int i=11;

    printf("%d",++i|i++);

}
retagged by

1 Answer

–2 votes
–2 votes

answer is 12.

++i will execute first so i becomes 12.

i++ will execute next .here i is still 12 because of post incrementation.

then | will exectue . binary of 12 is 0000 1100 .

priority is ++i(pre increment) > i++(post increment) > | (bitwise or)

12 | 12 =12 .

edited by

Related questions