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; }

  1. A. 4294967272 0
  2. B. 4294967272 1
  3. C. -24 1
  4. 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

Exams that ask this topic