suresh kanna <[EMAIL PROTECTED]> wrote:

hello sir/mam,

can anyone can explain me how this program is solved manually and in compiler....

main()

{

int x=5;

printf("%d %d %d ",x,x<<2,x>>2);

}

The answer for this is  5,1,20... but how the answer is approached...

can anyone helpme.....

reply in [EMAIL PROTECTED]

 

thz,

with warm wishes bye,

suresh

hello sir,

the answer is 5, 20, 1

integer 5 is written in binary as 0000 0101

x<<2 means 5<<2 i.e. 5 is left shifted by 2.

it looks like as follow

0000 0101

0000 1010   (shifting left by 1)

0001 0100   (shifting left by again 1, i.e. total shifting by 2). in decimal this is nothing but the 20 .

same way x>>2 means 5>>2 i.e. 5 is write shifted by 2

it looks like as follow

0000 0101

0000 0010   (shifting right by 1)

0000 0001   (shifting right by again 1, i.e. total shifting by 2). in decimal this is nothing but the 1 .

now u got it

--------------Vidya

 

 

 

 


Do you Yahoo!?
Jazz up your holiday email with celebrity designs. Learn more.

To unsubscribe : [EMAIL PROTECTED]




Yahoo! India Matrimony: Find your life partner online.

To unsubscribe : [EMAIL PROTECTED]




Yahoo! Groups Sponsor
ADVERTISEMENT
click here
Web Bug from http://us.adserver.yahoo.com/l?M=295196.4901138.6071305.3001176/D=groups/S=:HM/A=2128215/rand=993968244


Yahoo! Groups Links

Reply via email to