Question:What will be output when you will execute following c code?#include<stdio.h>
int main(){
signed x,a;
unsigned y,b;
a=(signed)10u;
b=(unsigned)-10;
y = (signed)10u + (unsigned)-10;
x = y;
printf("%d %u\t",a,b);
if(x==y)
printf("%d %d",x,y);
else if(x!=y)
printf("%u %u",x,y);
return 0;
}
Choose all that apply:
+ ExplanationTurbo C++ 3.0: 10 65526 0 0
Turbo C ++4.5: 10 65526 0 0
Linux GCC: 10 4294967286 0 0
Visual C++: 10 4294967286 0 0
a=(signed)10u;
signed value of 10u is +10
so, a=10
b=(unsigned)-10;
unsigned value of -10 is :
MAX_VALUE_OF_UNSIGNED_INT – 10 + 1
In turbo c 3.0 compiler max value of unsigned int is 65535
So, b = 65526
y = (signed)10u + (unsigned)-10;
= 10 + 65526 = 65536 = 0 (Since 65536 is beyond the range of unsigned int. zero is its corresponding cyclic vlaue)
X = y = 0