#include <iostream>
using namespace std;
int main() {
int n;
cin >> n;
cout << (n<<1);
return 0;
}
The left shift operator is shifting the leading zeros. For example,
for n = 5
, 101
should be left shifted to 011
I want output to be 3
for n = 5
but instead it is 10
cause of the leading zeros getting shifted.
I went through all other answers, but they were not as what I expected.
Another approach to shift bits is also appreciated.