ProgrammingVery hard
unsigned int u = 1; int s = -2; printf("%u", u + s); What is printed with 32-bit unsigned int?
- A. 4294967294
- B. -1
- C. 2
- D. 4294967295
Correct answer: D. 4294967295
s is converted to unsigned int, giving 2^32 - 2, and adding 1 wraps to 2^32 - 1.
More C Programming questions
- With int a = -1 and unsigned int b = 0, what does the expression a < b evaluate to?
- Using the extended Euclidean algorithm, what is the inverse of 10 modulo 17?
- What is the number of 1 bits in 0xF0F0 (a 16-bit value)?
- An 8-bit value 0b10010110 is rotated left by 3 positions within 8 bits. What is the result in decimal?
- unsigned char s = 0; for (int i = 1; i <= 100; i++) s += i; printf("%d", s); What is printed?
- What is (1ULL << 40) % 1000 in C?