ProgrammingVery hardGATE CS · Campus placements

uint8_t x = 0x81; uint8_t r = (uint8_t)((x >> 1) | (x << 7)); What is r?

  1. A. 0x40
  2. B. 0xC1
  3. C. 0xC0
  4. D. 0x81

Correct answer: C. 0xC0

This rotates x right by one bit: the low bit wraps to the top. x >> 1 gives 0x40 and the low byte of x << 7 is 0x80, so the OR is 0xC0.

More C Programming questions

Exams that ask this topic