P

Priyanka Tomar • 35.28K Points
Coach

Q. What is the output of the following code snippet? int x = 10; int y = 20; cout << (x >> 1);

  • (A) 5
  • (B) 10
  • (C) 20
  • (D) Error
  • Correct Answer - Option(A)
  • Views: 58
  • Filed under category C++

Explanation by: Priyanka Tomar
The right shift operator (>>) shifts the bits of x to the right by 1, effectively dividing x by 2. So, 10 >> 1 = 5.

You must be Logged in to update hint/solution

Discusssion

Login to discuss.


Question analytics