Multiple choice general knowledge

What will be printed as the result of the operation below: main() { int x=5; printf(“%d,%d,%dn”,x,x< <2,x>>2); }

  1. 4,21,1

  2. 5,20,0

  3. 5,5,5

  4. 5,20,1

Reveal answer Fill a bubble to check yourself
D Correct answer
Explanation

x = 5. x<<2 (left shift by 2) = 5 * 4 = 20. x>>2 (right shift by 2) = 5 / 4 = 1 (integer division). Output: 5,20,1. Left shift multiplies by 2^n, right shift divides by 2^n.