ProgrammingVery hardTCS NQT · Infosys
uint16_t a = 300, b = 300; uint16_t p = a * b; What is p?
- A. 90000
- B. 24464
- C. 25536
- D. 0
Correct answer: B. 24464
The product 90000 is computed in int and then reduced modulo 65536, giving 24464. This is a common hidden overflow in 16-bit storage.
More C Programming questions
- What does printf("%d", strcmp("apple", "Apple") > 0) print?
- A stair can be climbed by 1, 2 or 3 steps. How many ways are there to climb 4 stairs?
- #define N 3 and int a[N 2 + 1]; What is sizeof a / sizeof a[0]?
- int x = 5, y = 3; What does printf("%d", x & y | 4 ^ 1) print?
- unsigned int n = 3u; int k = -1; if (k > n) printf("yes"); else printf("no"); What is printed?
- Which type reliably holds the sum 1 + 2 + ... + 100000 = 5000050000?