raja.bhavanam
Junior Member level 3
Hi,
Recently I came across the below C question. I know the output but I want to know how compiler will analyse the comparison. Appreciate your views
Thanks,
-Raja
signed int is = -1;
unsigned int iu = is;
signed char cs = -1;
unsigned char cu = cs;
if (is == iu) printf("is and iu are equal\n");
else printf("is and iu are not equal\n");
if (cs == cu) printf("cs and cu are equal\n");
else printf("cs and cu are not equal\n");
Output:
is and iu are equal
cs and cu are not equal
Recently I came across the below C question. I know the output but I want to know how compiler will analyse the comparison. Appreciate your views
Thanks,
-Raja
signed int is = -1;
unsigned int iu = is;
signed char cs = -1;
unsigned char cu = cs;
if (is == iu) printf("is and iu are equal\n");
else printf("is and iu are not equal\n");
if (cs == cu) printf("cs and cu are equal\n");
else printf("cs and cu are not equal\n");
Output:
is and iu are equal
cs and cu are not equal