C
compcreator
I have tried the following program. The problem is it is printing
False
I checked values for a and b but there is something wrong with the
comparison.
I thing it might be because of signed and unsigned conversion.
Either b is upgraded to unsigned and the resulting value during
comparison is > 5 or a is downgraded to signed and the resulting value
is lower than -1.
void main()
{
unsigned int a = 5;
signed int b = -1;
if(b <= a)
printf("True");
else
printf("False");
}
Can somebody explain why is this happening....?
False
I checked values for a and b but there is something wrong with the
comparison.
I thing it might be because of signed and unsigned conversion.
Either b is upgraded to unsigned and the resulting value during
comparison is > 5 or a is downgraded to signed and the resulting value
is lower than -1.
void main()
{
unsigned int a = 5;
signed int b = -1;
if(b <= a)
printf("True");
else
printf("False");
}
Can somebody explain why is this happening....?