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 | |
|
|
Yahoo! Groups Links
- To reply to this message, go to:
http://groups.yahoo.com/group/Programmers-Town/post?act=reply&messageNum=4596
Please do not reply to this message via email. (more info)
- To visit your group on the web, go to:
http://groups.yahoo.com/group/Programmers-Town/
- To unsubscribe from this group, send an email to:
[EMAIL PROTECTED]
- Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service.
