New course! Every coder should learn Generative AI!
Try a free lesson0
Why output of the following code is 8?
int x = 2; Console.Write(x<<2); Thanks.
1 Answer
+ 6
In binary, x is 10(2).
<<, meaning pushing all bits to left, push those bits twice to left. Then it becomes 1000(2). And it's 8 in decimal.