Asked by Daniel
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.
Answers
Answered by
oobleck
power=1
dec = 0
read bin
for i=length(bin)-1 .. 0 {
dec += power if char[i] = 1
power *= 2
}
dec = 0
read bin
for i=length(bin)-1 .. 0 {
dec += power if char[i] = 1
power *= 2
}
There are no AI answers yet. The ability to request AI answers is coming soon!
Submit Your Answer
We prioritize human answers over AI answers.
If you are human, and you can answer this question, please submit your answer.