0

#include <stdio.h> void main() { int x = 1, z = 3; int y = x << 3; printf(" %d\n", y); }

8 is the output but why??

14th Jan 2021, 11:30 AM
yogesh
yogesh - avatar
3 Answers
+ 7
This is a binary operation and shift bits of x, 3 times left. int x = 1 in binary looks ...0001. After shifting 3 times left the binary looks ...01000 and this equals 8 in decimal.
14th Jan 2021, 11:53 AM
JaScript
JaScript - avatar
+ 4
Try it out in the Code Playground ...
14th Jan 2021, 11:31 AM
Alphin K Sajan
Alphin K Sajan - avatar