Left shift of number in C++ by R4R Team

What is Left shift ?
Basically,shifting are possible on binary bits.

Example-
Number is: 8
Its binary is 1000
Then one Left shift is 10000(i.e, 16 in decimal)

program:

#include< iostream>
int main() {
int n,a;
cout<<"Enter number"<< endl;
cin>>n;
a=n<< 1;
cout<<"One Left shift is "<< a;
a=n<< 2;
cout<<"Two Left shift is "<< a;
a=n<< 3;
cout<<"Three Left shift is "<< a;
}


output-

Enter number
3
One Left shift is 6
Two Left shift is 12
Three Left shift is 24

-In this program, we take an input of the integer decimal number.
-then we find the left shift by 1 bit,2 bit and 3 bit.




Leave a Comment:
Search
Categories
R4R Team
R4Rin Top Tutorials are Core Java,Hibernate ,Spring,Sturts.The content on R4R.in website is done by expert team not only with the help of books but along with the strong professional knowledge in all context like coding,designing, marketing,etc!