power=1
dec = 0
read bin
for i=length(bin)-1 .. 0 {
dec += power if char[i] = 1
power *= 2
}
Write a program that converts a binary number to decimal. The program should begin by reading the binary number from the user as a string.
1 answer