i cant figure out how i should write a c program regarding this problem...

when i enter a binary number,say 101101, the result would be the decimal equivalent of 45...

it goes like this,

1 0 1 1 0 1 equals
32 16 8 4 2 1

so,form right to left, it goes like 1,2,4,8,16,32,64,128,256,512,1024...so on...(like IP addressing,VLSM...)
it will add only on values of 1 and not 0...

counting is from right to left,but it wont start until 1 is the rightmost...

using if and then or loops is not allowed...only arithmetic operators...

thanks in advance...