C Programming, Justify with answer.!! | Sololearn: Learn to code for FREE!
Novo curso! Todo programador deveria aprender IA generativa!
Experimente uma aula grƔtis
+ 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 Respostas
+ 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