what is output of the following statetment?Printf(“%x”,
-1<<4); ?

Answer Posted / arupananda

Question is -1<<4
Answer to 16bit compiler
As -1 is a negative number,so compiler first convert this number with removing negative sign to 2's complement
Here -1 is given
so compiler first removes the -ve sign and then convert to 2's complement
Binary form of 1 for 16 bit compiler is 0000 0000 0000 0001
1's complement of 1 is 1111 1111 1111 1110
2's complement of 1 is 1111 1111 1111 1111(1+1's complement)
now do the left shift operation
1111 1111 1111 1111 << 4
which results 1111 1111 1111 0000
i.e equivalent to FFF0 in hex format
So the answer is FFF0 for 16 bit compiler
And for 32 bit compiler it is FFFF FFF0 (do same operation as 16 bit compiler)

Is This Answer Correct ?    1 Yes 1 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Does free set pointer to null?

575


How can a number be converted to a string?

617


what is the diffrenet bettwen HTTP and internet protocol

1398


What are external variables in c?

561


What is the difference between null pointer and wild pointer?

648






What are volatile variables in c?

539


How can I recover the file name given an open stream or file descriptor?

603


What is difference between scanf and gets?

622


Why is structure important for a child?

613


Explain the process of converting a Tree into a Binary Tree.

2119


Is it valid to address one element beyond the end of an array?

692


Can you explain what keyboard debouncing is, and where and why we us it? please give some examples

1670


State two uses of pointers in C?

646


Explain about the constants which help in debugging?

861


When is a “switch” statement preferable over an “if” statement?

657