ProgrammingModerateTCS NQT · Infosys
What is ~0u / 2 + 1 for a 32-bit unsigned int?
- A. 2147483647
- B. 2147483648
- C. 4294967295
- D. 2147483649
Correct answer: B. 2147483648
~0u is 4294967295, and halving gives 2147483647. Adding one yields 2147483648, the midpoint of the unsigned range.
More C Programming questions
- What does (unsigned int)(-1) % 10 evaluate to on a platform with a 32-bit unsigned int?
- How many ways are there to write 5 as an unordered sum of 1s and 2s?
- void rev(char s) { char e = s + strlen(s) - 1; while (s < e) { char t = s; s++ = e; e-- = t; } } After rev("abcde") runs on a writable…
- Which algorithm finds the maximum subarray sum of an array of n = 10^6 ints in time within a typical 1 second contest limit?
- char s = "hello"; What is strlen(s + 2)?
- int x = 1, y = 2, z = 3; int ptrs[3] = {&x, &y, &z}; What is ptrs[1] + ptrs[2]?