+ 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);

3rd Oct 2020, 10:29 AM
Sonam aafre
Sonam aafre - avatar
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
3rd Oct 2020, 12:15 PM
Minho
Minho - avatar
3rd Oct 2020, 10:38 AM
Abhay
Abhay - avatar
+ 2
Thank u so much ☺️☺️
3rd Oct 2020, 12:22 PM
Sonam aafre
Sonam aafre - avatar
+ 1
But answer to a=3 and b=4 aarha he
3rd Oct 2020, 11:38 AM
Sonam aafre
Sonam aafre - avatar