ProgrammingHardTCS NQT · Infosys
unsigned int u = 3; int s = -4; printf("%d", (int)u + s); What is printed?
- A. -1
- B. -7
- C. 2
- D. 9
Correct answer: A. -1
(int)u is 3, so 3 + (-4) is -1 with no unsigned conversion involved. A mixed unsigned and signed sum would give a very different value.
More C Programming questions
- How many leading zero bits does the 16-bit unsigned value 0x0100 have?
- What is the popcount of (1ULL << 40) | (1ULL << 3)?
- c is a char holding '5'. What is printf("%d", (c - '0') 2)?
- How many 1 bits does 0b10101 have?
- A table of size 7 uses h(k) = k % 7 with linear probing. Keys 14, 21, 7 and 0 are inserted in that order. In which slot does key 0 land?
- Linear probing with a tombstone-free delete: keys 0 and 7 both hash to slot 0 in a table of size 7. 0 is stored at slot 0 and 7 at slot 1…