ProgrammingHardGATE CS · Campus placements
Which expression clears the lowest three bits of an unsigned char x?
- A. x | 0x9
- B. x & ~7
- C. x ^ 0x6
- D. x & 0x7
Correct answer: B. x & ~7
~7 has ones everywhere except bits 0 to 2, so ANDing keeps all other bits and clears those three. x & 0x7 keeps only those bits.
More C Programming questions
- uint32t x = 0u; x -= 1; x = x / 2 + 1; What is x?
- int a[5]; int p = &a[4]; printf("%td", p - &a[0]); What is printed?
- What does printf("%d", '7' - '0' == 7) print?
- Reversing the list 1 -> 2 -> 3 -> 4 -> 5 in place with the usual three-pointer loop, what are head->v and head->next->v afterwards?
- In a list 1 -> 2 -> 3 -> 4 -> 2 where the last node points back to the node holding 2, Floyd's method runs slow = slow->next and fast =…
- A pointer-to-pointer loop deletes every node holding 2 from 2 -> 2 -> 3 -> 2 -> 1, using struct N pp = &head and advancing only when no…