ProgrammingVery hardGATE CS · Campus placements
uint8_t x = 0x81; uint8_t r = (uint8_t)((x >> 1) | (x << 7)); What is r?
- A. 0x40
- B. 0xC1
- C. 0xC0
- 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
- What is the value of 1 << 2 + 3 in C?
- int x = 2; printf("%d", x & 1 == 1); prints what?
- uint32t x = 1u; x <<= 31; x <<= 1; What is x afterwards?
- What is the value of (uint64t)1 << 40?
- uint64t computes 3 to the power 40 modulo 1000000007 with square-and-multiply, reducing after each multiplication. What is the result?
- uint32t x = 0x7FFFFFFFu; x = x 2u + 1u; What is x?