ProgrammingHardTCS NQT · Wipro

What is printed?

What is printed?
#include <stdio.h>
int main(void) {
    unsigned a[] = {5, 3};
    printf("%u", a[0] - a[1] * 2);
}
  1. A. 4294967294
  2. B. 1
  3. C. 4294967295
  4. D. 3

Correct answer: C. 4294967295

a[1] * 2 = 6, and 5 - 6 wraps modulo 2^32 to 4294967295. The signed value -1 is not what an unsigned expression produces.

More C Programming questions

Exams that ask this topic