-1
#include <stdio.h>
int main(void)
{
    if (sizeof(int) > -10)
        printf("YES\n");
   else 
        printf("NO\n");
   return 0;
}

why it is printing NO instead of YES? Because the size of int is 4bytes as per the compiler.And it is greater than -10.

SHOBHAN
  • 9
  • 3

1 Answers1

3

sizeof produces an unsigned value. When comparing a signed and unsigned integer, the signed value is converted to unsigned. The two’s complement value for -10 is much bigger than 4 when interpreted as unsigned.

Govind Parmar
  • 20,656
  • 7
  • 53
  • 85