Last Updated :
10 Apr, 2024
What will be the result of the below program in C++
#include <iostream>
using namespace std;
int main()
{
int x = 2, y = 3;
x = y << x;
y = x << y;
cout << (x >> 1) << \" \" << (y >> 1);
return 0;
}
(A) 48 6
(B) 6 40
(C) 40 6
(D) 6 48
Answer: (D)
Explanation: Value of x and y after bitwise left shift evaluation becomes 12 and 96 and after 1 bit right shift both becomes 6 and 48.
Share your thoughts in the comments
Please Login to comment...