+ 4
What will be the output of this code? And why?
#include <iostream> using namespace std; int main() { if(sizeof(int)>(-1)){ cout<<"True"; } else{ cout<<"False"; } }
5 ответов
+ 9
I think it is True because if I remember correctly, sizeof(int) = 4
EDIT: Just tried the code on code playground and I was wrong because sizeof returns a value of type size_t which is an unsigned type. Answer is False
+ 2
False
+ 2
False is absolutely right answer.
+ 2
false is right answer becoause the size of operater return the value in unsigned format but it is compared to -1 which is signed format bt this cant not happen u can not compare unsigned with signed therefore the compilor converts the -1 into unisgned which is much grratrr than size of int hence it prints false
0
how you say false is absolutely correct answer?