+ 2

why out put = 1

#include <iostream> using namespace std; int main() { int a=2; int b=3; int c=a^b; cout << c << endl ; return 0; }

9th Jun 2017, 4:24 PM
wachirut chaiwong
wachirut chaiwong - avatar
1 Odpowiedź
+ 6
^ is a bit-wise xor operator which return 1 when corresponding bits in two operand are different 0 ^ 0 = 0 1 ^ 1 = 0 0 ^ 1 = 1 1 ^ 0 = 1 2 = 0010 3 = 0011 Now 2 ^ 3 = 0 0 1 0 0 0 1 1 --------- 0 0 0 1 Hope that helps
9th Jun 2017, 4:51 PM
देवेंद्र महाजन (Devender)
देवेंद्र महाजन (Devender) - avatar