+ 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 - 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 - avatar
+ 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
CarrieForle - avatar