ProgrammingVery hardTCS NQT · Infosys
uint8_t a = 0xF0, b = 0x3C; uint8_t c = a & ~b; What is c?
- A. 0x30
- B. 0xC0
- C. 0xF0
- D. 0x0C
Correct answer: B. 0xC0
~b promotes to int and ANDing with a keeps only the bits set in a but clear in b. Those bits are 1100 0000, which is 0xC0.
More C Programming questions
- uint16t a = 3, b = 5; printf("%d", (a - b) > 0); prints what?
- uint32t p = 65536u 65536u; What is p?
- uint64t f = 1; for (uint64t i = 1; i <= 21; i++) f = i; What is f after the loop?
- How many subsets of {1, 2, 3, 4, 5} have a bitwise XOR of their elements equal to 0? Count the empty set.
- How many integers i with 1 <= i <= 100 have bit 3 (value 8) set in their binary form?
- uint32t x = 0x12345678u; the 32-bit left rotation by 8 bits, written as (x << 8) | (x >> 24), gives what value?