Multiple choice softskills creativity

Output?? #include int main() { unsigned int i = 5; int j = -20; if(i+j > 5) printf(">5=%d\n",j+i); else printf("<5=%d\n",i+j); return 0; }

  1. >5=-15

  2. <5=-15

  3. <5=15

  4. >5=15

Reveal answer Fill a bubble to check yourself
A Correct answer
Explanation

When mixing signed and unsigned integers, C promotes the signed value to unsigned. -20 becomes a very large positive number (2^32-20 for 32-bit int). i+j (5 + large unsigned) exceeds 5, so the if condition is true. The printf uses %d to format j+i, which is -15 when viewed as signed. Option A is correct: >5=-15.

AI explanation

Because i is unsigned int, when i + j is evaluated the signed j is converted to unsigned, turning -20 into a very large unsigned value, so i+j is far greater than 5 and the if branch runs. When that same underlying bit pattern is printed back with %d (signed interpretation), it reads out as -15, giving the output &gt;5=-15. This mix of unsigned promotion with signed printf conversion is what makes the "greater than 5" branch print a negative-looking number.