Using bitwise (right shift)

Can we use bitwise operator, more specifically right shift operator to change “num” after we extract the last bit?

e.g. let num = 101
after extracting the LSB ( 1 ), can we do the following:

num = num >> 1; to change num?

while(num > 0){
a = num%10;
dec_num = dec_num + (a*(2^p));
num = num>>1;
p = p++;
}

can this be done?

@wtakashish,
Please use Coding Blocks IDE to share your codes, don’t just copy/paste here.
num=num>>1 is same as num=num/2, so you can use either.

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.