Bitwise Shift Operator

  1. We learned in Chapter 2 that the bitwise shift operator are equivalent to multiplying/dividing an integer by a power of 2.
  2. For example, if n = 3, then "n = n << 2;" or "n <<= 2" is equivalent to multiplying n by 4.
  3. Now let's consider a variable with the data type "signed char". What is the minimum value such a variable can possess?
  4. Let n be given such a value. Now write a program to calculate the value of n>>1.
  5. Try to also find the values of n>>2, n>>3, n>>4, n>>5, n>>6, n>>7.
  6. Discuss the result with your classmates, and write down your observation.