ProgrammingHardTCS NQT · Infosys
uint16_t a = 40000, b = 40000; uint32_t s = a + b; What is s?
- A. 14464
- B. 80000
- C. 0
- D. 65536
Correct answer: B. 80000
a and b promote to int, so a + b is 80000, which fits in uint32_t. Storing the sum in a 16-bit type would instead give 14464 because of the wrap.
More C Programming questions
- uint32t x = 0x80000001u; x = (x << 1) | (x >> 31); What is x?
- unsigned char c = 0x7F; c = c 2 + 2; What is c?
- For the array {4, 1, 3}, how many index pairs i < j have a[i] > a[j]? These pairs are called inversions.
- How many binary strings of length 5 contain no two adjacent 1s?
- char s[] = "abc"; s[0] = 'x'; printf("%s", s); prints what?
- unsigned int n = 1u; unsigned int r = n << 31; What is r?