Can anyone explain why no is printing | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 2

Can anyone explain why no is printing

#include <stdio.h> int main() { if(sizeof(int) > -1){ printf("yes"); } else printf("no"); return 0; }

30th Nov 2019, 12:04 PM
Preity
Preity - avatar
2 Answers
+ 5
Because sizeof returns an unsigned long long. As a result -1 is converted to the unsigned long long equivalent, which is 2^64 - 1. The size of an int is definitely smaller than that.
30th Nov 2019, 12:11 PM
Dennis
Dennis - avatar
+ 3
Just like ~ swim ~ said in one of his answer and I still remember. Try printing this line and see- printf ("%lu", (long unsigned int)(-1));
30th Nov 2019, 12:15 PM
Avinesh
Avinesh - avatar