1⟩ Do you know what are bitwise shift operators in C Programming?
The bitwise operators are used for shifting the bits of the first operand left or right. The number of shifts is specified by the second operator.
Expression << or >> number of shifts
Ex:
number<<3;/* number is an operand - shifts 3 bits towards left*/
number>>2; /* number is an operand – shifts 2 bits towards right*/
The variable number must be an integer value.
For leftward shifts, the right bits those are vacated are set to 0. For rightward shifts, the left bits those are vacated are filled with 0’s based on the type of the first operand after conversion.
If the value of ‘number’ is 5, the first statement in the above example results 40 and stored in the variable ‘number’.
If the value of ‘number’ is 5, the second statement in the above example results 0 (zero) and stored in the variable ‘number’.