[prev] 26 [next]

Exercise 5: Bit Shifting Exercises

  • Write a line of code to multiply an unsigned int by 2 using bit shift operations.
  • Write a line of code to divide an unsigned int by 4 using bit shift operations.
  • Write a line of code to set the 3rd least significant bit of an unsigned int to 1.
  • Write a function to find 2 to the power of n.
  • Write a function to print out an int in binary.