ProgrammingModerateTCS NQT · Wipro
What is printed? Assume unsigned short is 16 bits and int is 32 bits.
What is printed? Assume unsigned short is 16 bits and int is 32 bits.
#include <stdio.h>
int main(void) {
printf("%d", (unsigned short)(0xFFFF + 1));
}- A. 65536
- B. 0
- C. 65535
- D. 1
Correct answer: B. 0
0xFFFF + 1 is 65536 in int, and conversion to a 16-bit unsigned type reduces it modulo 65536 to 0.
More C Programming questions
- How many binary strings of length 4 contain no two consecutive 1s? Compute with this recursive program. c #include <stdio.h> int f(int n)…
- What is printed? c #include <stdio.h> int main(void) { unsigned char a = 100, b = 200; unsigned char s = (unsigned char)(a + b) / 2…
- How many times does the loop body run? c #include <stdio.h> int main(void) { int c = 0; for (int i = 0, j = 0; i < 4 && j < 4; i++, j +=…
- What is printed? c #include <stdio.h> void inc(int p, int n) { while (n--) (p++)++; } int main(void) { int a[] = {1, 2, 3}; inc(a, 2)…
- What is printed? c #include <stdio.h> int main(void) { unsigned short s = 1; s <<= 15; printf("%d", s); }
- What is printed? c #include <stdio.h> int main(void) { printf("%d", 'a' < 'b' && 'b' < 'c'); }