find output with reason:- main() { if(sizeof(int)>-1) printf("Hello"); else printf("Hii") }



12/14/2019 11:02:04 AM

Amit Dubey

4 Answers

New Answer


I guess sizeof returns an unsigned integer. In that case, 4 < -1 because you're comparing unsigned and signed values. That's why it's printing Hii


sizeof(int) is of type size_t, which is an unsigned integer type. So in the expression if(sizeof(int) > -1), -1 is converted to an unsigned integer, which is very big.


sizeof(int)=4 (signed) and -1 =4,294,967,295(signed) So 4>4,294,967,295 is false . That's why its printing Hii.


why it is not so when i print the value of sizeof(int), it does not show any unsigned value. why??