Multiple choice

void main() { signed x; unsigned y; x= 10 + - 10u + 10u + -10; y=x; if(x==y) printf("%d %d", x, y); else if(x!=y) printf("%u %u", x, y); }.

Which of the following is the output of the program?

  1. Compilation error

  2. 0, 0

  3. 65536, 0

  4. Runtime error

  5. 65536, - 10

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

In any binary operation of dissimilar data type, lower data type operand always automatically type casted into the operand of higher data type before performing the operation and result will be higher data type. x= 10 + (-10u) + 10u + (-10) x= 10 + (-10) + 10 + (-10) x=0 so y=0