0
int main()
{
    if(sizeof(double) > -1)
        printf("M");
    else
        printf("m");
    return 0;
}

I expected the output to be M but it is m. Can anybody please explain me the reason for the output?

Laurel
  • 5,965
  • 14
  • 31
  • 57
vas19
  • 9
  • 1

1 Answers1

3

That's because sizeof returns a size_t value, that is, a unsigned integer type, so, -1 will overflow.

Educorreia
  • 375
  • 5
  • 21