#include <stdio.h>
unsigned int a=1;
int b=-2;
int main()
{
if(a > b)
{
printf("Ok");
}
else
{
printf("Not Ok");
}
printf(" a=%x , b=%x",a,b);
return 0;
}
// gives output Not ok , due to binary comparison
// but when int is changed to char comparison happen correctly , why ?
#include <stdio.h>
unsigned char a=1;
char b=-2;
int main()
{
if(a > b)
{
printf("Ok");
}
else
{
printf("Not Ok");
}
printf(" a=%x , b=%x",a,b);
return 0;
}
// prints Ok