ProgrammingHardTCS NQT · Accenture

What is printed?

What is printed?
#include <stdio.h>
int main(void) {
    unsigned x = 0xFFFFFFFEu;
    x += 3;
    printf("%u", x);
}
  1. A. 2
  2. B. 0
  3. C. 4294967297
  4. D. 1

Correct answer: D. 1

0xFFFFFFFE + 3 = 2^32 + 1, which wraps to 1 in unsigned int.

More C Programming questions

Exams that ask this topic