+ 7
What is << operator in cout
below code outputs 2 instead of 11. why ? cout << (1<<1);
4 Answers
+ 10
because here 1<<1 act as left shift operator..
1<<1 value is 2 and 2 print by cout..
+ 8
<< is bitwise left shift operator
The left-shift operator causes the bit pattern in the first operand to be shifted to the left by the number of bits specified by the second operand.
So 1 << 1 = `0000 0010`
evaluates to 2
+ 3
never come across this operation...any usecase of same will be helpful to make me digest this easily
+ 1
<< operator is also called as insertion operator