Can someone pls tell me how is the operation different in the following two code snippets?


Code:
main()
{
int temp=20742;

short temp1;
temp1 = temp << 8;
printf("The vaue is %d\n",temp1>>8);}
result:6

Code:
main()
{
int temp=20742;

short temp1;
temp1 =(temp << 8)>>8;
printf("The vaue is %d\n",temp1);}
result: 20742

If I want to do the operation that I have done in the first code snippet in a single line without using any temp variables, how do I do it?

Thanks

Last edited by shabbir; 4Sep2006 at 16:58.. Reason: Code formating.