ProgrammingModerateTCS NQT · Infosys
uint16_t a = 3, b = 5; printf("%d", (a - b) > 0); prints what?
- A. 0
- B. 1
- C. -2
- D. 65534
Correct answer: A. 0
Both operands are promoted to int, so a - b is -2 and the comparison is false. The wrap to 65534 happens only if the difference is stored back into a uint16_t first.
More C Programming questions
- 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?
- What is the Hamming distance between a = 0b1011 and b = 0b0110, that is the number of bit positions where they differ?