Sunday 24 March 2013

if(~0 == (unsigned int)-1)


 void main()
         {
if(~0 == (unsigned int)-1)
printf(“You can answer this if you know how values are represented in memory”);
         }  
 Answer
You can answer this if you know how values are represented in memory
Explanation
~ (tilde operator or bit-wise negation operator) operates on 0 to produce all ones to fill the space for an integer. –1 is represented in unsigned value as all 1’s and so both are equal.

Blog Author: Vijay Kumar

No comments:

Post a Comment