ProgrammingVery hardProduct company OA

What is printed?

What is printed?
#include <limits.h>
printf("%u %d", UINT_MAX + 1u, UINT_MAX == -1);
  1. A. 0 1
  2. B. 0 0
  3. C. 4294967296 0
  4. D. Undefined: the addition overflows

Correct answer: A. 0 1

Unsigned arithmetic wraps modulo 2^N by definition, so UINT_MAX + 1u is 0, never undefined. In UINT_MAX == -1 the int −1 is converted to unsigned int, which gives UINT_MAX, so the comparison is true.

More C Programming questions

Exams that ask this topic