P

Priyanka Tomar • 35.28K Points
Coach

Q. What will be the output of the following code?

int x = 5;
cout << (x << 1);

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

Explanation by: Priyanka Tomar
The left shift operator (<<) shifts bits to the left, effectively multiplying by 2. So, 5 << 1 results in 10.

You must be Logged in to update hint/solution

Discusssion

Login to discuss.


Question analytics