0
bitwise xor and not operator
https://code.sololearn.com/cgYFcQ92dxUs/#c https://code.sololearn.com/cCRwH0pbo0wj/#c Can anyone explain me the above code.. How the output comes as 10 1 and 1
2 Réponses
+ 2
In first code, xor makes bits the same 0 and bits different 1 so:
x=0b0001
y=0b1010
x^=y makes x 0b1011
y^=x makes y 0b0001
x^=y makes x 0b1010
In the second code:
!a?b?!c:!d:a
is the same as:
if (!a)
if (b)
!c
else
!d
else
a
Since a is non-zero, it is true so not a is false so the value of a is printed.
+ 1
John Wells Thank u so much