+ 1
Can some one expain me ?
Int main() Int a=4,b=3; a=a^b; b=a^b; a=a^b; Printf("after xoR ,a=%d and b=%d",a,b);
4 Respuestas
+ 10
Sonam aafre
This is called Bitwise Exclusive OR ^
It works like this.
1st operand 2nd operand resultant bit
0 0 0
0 1 1
1 0 1
1 1 0
a = 4 = 0 0 0 0 0 1 0 0 (in binary)
b = 3 = 0 0 0 0 0 0 1 1
Now compare the corresponding bit of first operand with second operand.
a = a^b = ( 0 0 0 0 0 1 0 0 ) ^ (0 0 0 0 0 0 1 1) = 0 0 0 0 0 1 1 1
b = a^b = (0 0 0 0 0 1 1 1) ^ (0 0 0 0 0 0 1 1) = 0 0 0 0 0 1 0 0 = 4
a = a^b = (0 0 0 0 0 1 1 1) ^ (0 0 0 0 0 1 0 0 ) = 0 0 0 0 0 0 1 1 = 3
That's why result is a = 3 and b = 4.
https://www.sololearn.com/learn/4074/?ref=app
+ 2
See this page
https://en.m.wikipedia.org/wiki/Bitwise_operations_in_C
+ 2
Thank u so much ☺️☺️
+ 1
But answer to a=3 and b=4 aarha he