ProgrammingHardTCS NQT · Wipro
What is printed? Assume unsigned short is 16 bits.
What is printed? Assume unsigned short is 16 bits.
#include <stdio.h>
int main(void) {
unsigned short y = 60000;
y += 10000;
printf("%d", y);
}- A. 4464
- B. 70000
- C. 5536
- D. 3536
Correct answer: A. 4464
60000 + 10000 = 70000, and 70000 - 65536 = 4464 is the value kept in a 16-bit unsigned short. The result 3536 comes from taking 65536 - 62000 by mistake.
More C Programming questions
- What is printed? c #include <stdio.h> void gen(int d, int v) { if (d == 0) { printf("%d ", v); return; } gen(d - 1, v 2 + 1); gen(d - 1, v…
- What is printed? c #include <stdio.h> unsigned inv(unsigned g) { unsigned n = 0; for (; g; g >>= 1) n ^= g; return n; } int main(void) {…
- What is printed? c #include <stdio.h> int main(void) { int dp[16] = {0}; int sum = 0; for (int i = 1; i < 16; i++) dp[i] = dp[i >> 1] + (i…
- Assume int is 4 bytes with 4-byte alignment and char is 1 byte. What is printed? c #include <stdio.h> struct A { char c; int i; char d; }…
- How many subsets of {1, 2, 3, 4} (the empty set included) have an XOR of zero? c #include <stdio.h> int main(void) { int count = 0; for…
- What is printed? Assume int is 32 bits. c #include <stdint.h> #include <stdio.h> int main(void) { uint8t b = (uint8t)-200; printf("%d"…