ProgrammingHardTCS NQT · Wipro
What is printed? Assume uint16t is 16 bits.
What is printed? Assume uint16_t is 16 bits.
#include <stdint.h>
#include <stdio.h>
int main(void) {
uint16_t x = 60000;
uint16_t y = x * 2;
printf("%d", y);
}- A. 120000
- B. -11072
- C. 55000
- D. 54464
Correct answer: D. 54464
x * 2 is 120000 in int, and storing it in uint16_t keeps 120000 mod 65536 = 54464. The signed reading -11072 comes from treating the 16-bit pattern as two's complement.
More C Programming questions
- How many ways are there to make 10 from unlimited coins of value 2, 3 and 5? Compute with this program. c #include <stdio.h> int ways(int…
- What is the length of the longest common subsequence of ABCBDAB and BDCABA? The program computes it by plain recursion without a table…
- How many islands does this 4-connected flood-fill count find in the 3 by 3 grid "101", "010", "101"? Compute with the program. c #include…
- How many of these statements are true when x = 255? Count them with this program. c #include <stdint.h> #include <stdio.h> int main(void)…
- What is printed? c #include <stdio.h> int main(void) { unsigned a = 3; int b = -5; printf("%d", (a + b) > 0); }
- What is printed? c #include <stdio.h> #include <string.h> int main(void) { sizet n = 0; printf("%d", n - 1 > 100); }