ProgrammingHardTCS NQT · Wipro
What is printed?
What is printed?
#include <stdint.h>
#include <stdio.h>
int main(void) {
int16_t a = 200, b = 200;
int p = a * b;
printf("%d %d", p, p > 32767);
}- A. 40000 0
- B. 25536 1
- C. -25536 0
- D. 40000 1
Correct answer: D. 40000 1
The operands are promoted to int, so the product 40000 is exact and exceeds the int16_t range. The comparison p > 32767 is therefore 1.
More C Programming questions
- What is printed? c #include <stdint.h> #include <stdio.h> uint16t sat(uint16t a, uint16t b) { uint32t p = (uint32t)a b; return p > 65535u…
- What is printed? c #include <stdio.h> int main(void) { int m[4][4]; for (int i = 0; i < 4; i++) for (int j = 0; j < 4; j++) m[i][j] = i 4…
- How many pairs (i, j) with i < j satisfy a[i] < a[j] for a = {3, 1, 4, 2}? Compute with this program. c #include <stdio.h> int main(void)…
- What is printed? c #include <stdio.h> int main(void) { int a[] = {1, 2, 3}, cnt[3], total = 0; for (int i = 0; i < 3; i++) { cnt[i] = 1…
- How many binary strings of length 5 contain no two adjacent 1s? Compute with this recursive program. c #include <stdio.h> int f(int n) {…
- What is printed? c #include <stdio.h> struct item { int w, v; }; int main(void) { struct item items[] = {{1, 10}, {2, 20}, {3, 30}}…