+ 2
What should be the output of this program and why?
#include <iostream> using namespace std; int main() { unsigned int a=23; signed int b=-23; if(a>b){ cout<<"True"; } else{ cout<<"False"; } }
3 odpowiedzi
+ 3
output False.
because a is unsigned and b is signed. everytime you compare unsigned number with signed number , computer automatically cast signed to unsigned.Therefor,b become (2^32-23) bigger than a.
+ 2
false bcoz - 23 is converted into unsigned automatically and hence it has much greater value than 23 hence it prints false
+ 1
Should output False as 23 is not greater than 23, but is equal to. a >= b however, would output True.