Von Neuman loves Binary

I am facing problem in this question.

Hi Rajat,
You’ve been given a binary number, and your task is to convert it to a decimal number.
example: 1101 in binary is equal to 1*(2^3) +1*(2^2) + 0*(2^1) + 1*(2^0) = 13 and so on.
For further help, could you please specify exactly what problem you are facing?

I know this that I have to convert this into decimal but could not understand how to convert?

Start traversal from rightmost digit and keep a base variable. As you extract digits multiply base by 2 and multiply the digit with base. Also, maintain a ans variable in which you add base*digit.

If you have any further queries then please let me know! Otherwise, please mark the doubt as resolved :slight_smile: