ProgrammingModerateTCS NQT · Infosys
uint32_t t = 2000000000u + 2000000000u; What is t?
- A. 4000000000
- B. -294967296
- C. 3705032704
- D. 0
Correct answer: A. 4000000000
The sum 4000000000 is below 2^32 = 4294967296, so no wraparound occurs. A signed 32-bit int would have overflowed here, which is why the unsigned type matters.
More C Programming questions
- char buf[10]; char a = buf + 2, b = buf + 9; What does printf("%td", b - a) print?
- struct P { int x, y; } arr[4]; struct P p = arr; p += 2; What is p - arr?
- #define MIN(a,b) ((a)<(b)?(a):(b)). What does printf("%d", MIN(MIN(3,1),2)) print?
- int x = 5; printf("%d", x > 3 ? x - 3 : x + 3); What is printed?
- What does printf("%d", (4, 5) 2) print?
- int x = 0, y = 1; What does printf("%d", !x == y) print?