A

Admin • 833K Points
Coach

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

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

Explanation by: Admin

The compound assignment operator (<<=) shifts the bits of x to the left by 1, effectively multiplying x by 2. So, x becomes 20.

You must be Logged in to update hint/solution

Discusssion

Login to discuss.

Be the first to start discuss.