ProgrammingHardTCS NQT · Infosys
unsigned int x = 1u; x = ~x; What is x?
- A. 0
- B. -2
- C. 1
- D. 4294967294
Correct answer: D. 4294967294
~1u is all bits set except bit 0, which for a 32-bit unsigned int is 4294967294. Unsigned NOT never produces a negative value.
More C Programming questions
- unsigned int u = 5u; int s = -5; printf("%s", (u + s == 0) ? "yes" : "no"); What is printed?
- uint32t mask = 0; for (int i = 0; i <= 30; i += 3) mask |= 1u << i; How many set bits does mask have?
- unsigned int v = (unsigned int)(-2); printf("%X", v); What is printed?
- int a[3] = {1, 2, 3}; int p = a; int (q)[3] = &a; printf("%d", (q + 2) + (p + 1)); What is printed?
- unsigned char x = 0; x--; What is x?
- Which statement about the return value of strcmp is true?