ProgrammingHardTCS NQT · Infosys · Product Company SDE
What is the output of this C program (assume a typical 64-bit platform: int 32 bits, long and pointers 64 bits)? #include <stdio.h> int main(void) { unsigned int u = 26; u -= 50; printf("%u %d", u, u > 100); return 0; }
- A. 4294967272 0
- B. 4294967272 1
- C. -24 1
- D. 24 1
Correct answer: B. 4294967272 1
Unsigned arithmetic wraps modulo 2³²: 26 − 50 = 4294967272 (4294967296 − 24), which is greater than 100, so the comparison prints 1.
More C Programming questions
- What is the output of this C program (assume a typical 64-bit platform: int 32 bits, long and pointers 64 bits)? #include <stdio.h> int…
- What is the output of this C program (assume a typical 64-bit platform: int 32 bits, long and pointers 64 bits)? #include <stdio.h> int…
- What is the output of this C program (assume a typical 64-bit platform: int 32 bits, long and pointers 64 bits)? #include <stdio.h> int…
- What is the output of this C program (assume a typical 64-bit platform: int 32 bits, long and pointers 64 bits)? #include <stdio.h> int…
- What is the output of this C program (assume a typical 64-bit platform: int 32 bits, long and pointers 64 bits)? #include <stdio.h> int…
- Assume a 64-bit LP64 ABI. What is printed? c int a[4] = {1,2,3,4}; int (p)[4] = &a; printf("%d %d %zu", (p)[2], p, sizeof(p));