C Programming, Justify with answer.!! | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

C Programming, Justify with answer.!!

#include<stdio.h> int main() { if(sizeof(int) > - 1) printf("Yes"); else printf("No");

28th Aug 2020, 2:16 PM
shrijith
shrijith - avatar
2 Answers
+ 5
Because sizeof(int) returns unsigned int(that is positive integers) and it makes no sense comparing unsigned int with signed(negative integers), so its false. hence No is printed. NOT SATISFIED? Read this... https://stackoverflow.com/questions/5416414/signed-unsigned-comparisons
28th Aug 2020, 2:23 PM
Rohit
+ 3
As RKK said, sizeof returns unsigned int. While comparing unsigned int to signed int, signed implicitly converts to unsigned. -1 converts to unsigned is 2^32-1. Thus the comparation returns false.
28th Aug 2020, 2:42 PM
你知道規則,我也是
你知道規則,我也是 - avatar