ProgrammingHardTCS NQT · Infosys

What is printed?

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

Correct answer: C. 1

x - 6 wraps to UINT_MAX, which is greater than 0, so the comparison is 1.

More C Programming questions

Exams that ask this topic