ProgrammingHardGATE CS

What is printed?

What is printed?
int a = -1;
unsigned int b = 1;
printf("%d %d", a < b, a < (int)b);
  1. A. 1 1
  2. B. 1 0
  3. C. 0 0
  4. D. 0 1

Correct answer: D. 0 1

In a < b the signed -1 is converted to unsigned (a huge value), so it is false; with the cast both are signed and -1 < 1.

More C Programming questions

Exams that ask this topic