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,771
  • 12
  • 29
  • 54
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
  • 300
  • 6
  • 19