0 0 votes If the following fragment (assume negative numbers are stored in 2's complement form) unsigned i=1; int j=-4; printf("%u",i+j); prints x then printf("%d", 8*sizeof(int)); outputs an integer that is same as (log in the options are of base 2) a)8*log(x+3) b)log(x+3) c)unpredictable value d)none of the above Programming in C + – Sanjay Sharma 1.4k views answer comment Share Follow Print See 1 comment 1 1 comment reply Akriti sood commented Mar 1, 2017 reply Follow flag sir,in first printf statement,format specifier is unsigned and -4 + 1 = -3 but -3 cant be prited as it is signed,hence 3 will be printed which is x. now second printf statment prints 8* size of int which is 8*4 =32 //if size of int is 4 OR 8* 2 =16 if size of int is 2. option A - 8 * log (3 + 3) =8 *log 6 option B - log 6 i guess answer depend upon size of INT which is system dependent. pls correct me 0 0 replyShare Please log in or register to add a comment.
1 1 vote Is answer a here Kaluti answered Feb 28, 2017 Kaluti comment Share Follow See 1 comment 1 1 comment reply Sanjay Sharma commented Feb 28, 2017 reply Follow flag nopes 0 0 replyShare Please log in or register to add a comment.
0 0 votes Option (d) None of the above. The correct expression would be log(x + 2) (Not present in the options). The first printf would produce (UINT_MAX – 2) == (4294967293) == ((2**32 – 1) – 2). The second printf basically prints the number of bits in an int. We can take x, add 2, (which would set all the bits), and then take a log2 to get the number of bits present in an int. felix59 answered Dec 9, 2022 felix59 comment Share Follow 0 reply Please log in or register to add a comment.