c - What does this code do? -
#include<stdio.h> int main() { int i=4, j=8; printf("%d, %d, %d\n", i|j&j|i, i|j&j|i, i^j); return 0; } the output : 12,12,12
why above output displayed ? can explain me ?
i | j&j | i bitwise or between i, i , j&j (& has priority on |). equivalent i | j, so:
i = 0b00000100 = 4 j = 0b00001000 = 8 i|j = 0b00001100 = 12 i ^ j here same i | j since there no single bit set 1 both in j , i.
Comments
Post a Comment