Tell us bitwise shift operators?
Submitted by: AdministratorThe 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'.
Submitted by: Administrator
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'.
Submitted by: Administrator
Read Online C Preprocessor Job Interview Questions And Answers
Top C Preprocessor Questions
☺ | Tell us bitwise shift operators? |
☺ | Can you please explain the scope of static variables? |
☺ | What do you know about the use of bit field? |
☺ | What is typedf? |
☺ | Do you have any idea about the use of "auto" keyword? |
Top C Programming Categories
☺ | C Functions Interview Questions. |
☺ | C Pointers Interview Questions. |
☺ | C Preprocessor Interview Questions. |