Hi Ankit,
>it still diplays -1. i could not understand why on right shift the sign bit is not changed to 0 whats happening here?
You are right shifting a signed number. In a 2's complement machine, the MSb is used to indicate a negative number; and will be replicated on right shift.
For details on this kind of magic bit twiddling, get the fantastic book Hacker's Delight by Henry S. Warren, Jr.
HTH, --Eljay