ProgrammingModerateGATE CS · Campus placements
uint8_t x = 0xB4; What is the lowest set bit of x, computed as x & (uint8_t)-x?
- A. 0x80
- B. 0xB0
- C. 0x08
- D. 0x04
Correct answer: D. 0x04
0xB4 = 1011 0100, and its lowest set bit is 0x04. The cast of -x wraps to 0x4C, and ANDing that with 0xB4 keeps only 0x04.
More C Programming questions
- uint8t rev(uint8t x) { uint8t r = 0; for (int i = 0; i < 8; i++) { r = (uint8t)((r << 1) | (x & 1)); x >>= 1; } return r; } What is…
- int a[] = {4, 9, 16}; int p = a; What is (p + 2)[-1]?
- To compute a b mod m with 0 <= a, b < m <= 1000000007 in a competitive program, which expression is correct?
- Which expression tests whether bit k of an unsigned x is set?
- int x = 0x1F; What does printf("%d", 07 + 0x1F) print?
- uint32t x = 0xFFFFFFFFu; How many times does while (x > 0) x >>= 1; execute its body, counting from the start?