ProgrammingHardAccenture · Capgemini · C

What is the output of this C program (assume a typical 64-bit platform: int 32 bits, long and pointers 64 bits, double 8 bytes, structs aligned to their widest member with no packing pragma)? #include <stdio.h> int main(void) { unsigned char a = 250, b = 10; unsigned char c = a + b; printf("%d", c); return 0; }

  1. A. 255
  2. B. 260
  3. C. 0
  4. D. 4

Correct answer: D. 4

unsigned char wraps modulo 256: 250+10=260, and 260 mod 256 = 4.

More C Programming questions

Exams that ask this topic