0

In the 11th line of the below java code,how the value of 'a' get as 3

https://code.sololearn.com/cD22YP8mTpXK/?ref=app

6th Aug 2018, 4:45 PM
Pulsara Sandeepa
Pulsara Sandeepa - avatar
3 Answers
+ 3
int a=1; int b=2; int c=3; a|=4; // a becomes 5 b>>=1; c<<=1; // c becomes 6 a^=c; // a(5) XOR c(6) = 3 In binary: 5: 00000101 6: 00000110 --------------------- ^ (XOR) 3: 00000011 XOR yields 1 if the first bit and second bit are different, it yields 0 if both are equal. Hth, cmiiw
6th Aug 2018, 4:55 PM
Ipang
+ 1
thank you very much for the explanation it is very clear to understand....!
6th Aug 2018, 5:00 PM
Pulsara Sandeepa
Pulsara Sandeepa - avatar
+ 1
You're welcome, glad if it helps : )
6th Aug 2018, 5:34 PM
Ipang