0
What is the output and how dose it came ? #include <iostream> int main() { std::cout << (10 & 6) << std::endl; std::cout << (10 | 6) << std::endl; return 0; }
3 ответов
+ 5
& and | are bitwise operators in c++ so it will do operation using each binary bits of the operant, in given code binary of
10 - 1010 and 6 - 0110
so
1&1 =1
1&0=0
0&1=0
0&0=0
1010
&&&&
0110
--------
0010
so 10&6 will be 0010 = 2
similarly
1|1 =1
1|0=1
0|1=1
0|0=0
so 10|6 will be 1110=14
0
Thx hussain got it .
Legacy , i didn't get your point .
Thx all .
Text me back ASHMIL HUSSAIN at x.333 @ msn . com
0
u can contact me in ashmilhussain@gmail.com