BITWISE OPERATORS

int x = 5, y = 2, z = 5;
cout << ( z&x<<y ) << endl;
What will be the output of the above code?

Now, first we compute (x<<y) i.e. 5<<2 = 20 (10100).
Next z&20 i.e. 5&20 = 20.

So the anser should be 20 right ?

@shahpankti931 5&20 = 4
10100 (20)
00101 (5)
and of these two = 00100 = 4
i hope its cleared if yes dont forget to hit like and mark resolved :smiley:

1 Like