Convert Binary To Decimal

Write a program to convert binary to decimal

Binary is a base-2 number system. It uses only two digits: 0 and 1. The digits are called bits. A bit is the smallest unit of information in a computer. A bit can be either 0 or 1. A bit can be used to represent a single value, such as 0 or 1, or it can be used to represent a single state, such as on or off.

To convert a binary number to decimal, we can use the following algorithm:

  1. Multiply the first bit by 2^0.
  2. Multiply the second bit by 2^1.
  3. Multiply the third bit by 2^2.
  4. Multiply the fourth bit by 2^3.
  5. Repeat steps 3 and 4 until the last bit.
  6. Add the results of all the multiplications.
  7. The decimal number is the sum of all the multiplications.
Input : 1010 Output : 10

Contributors

This program is made possible by the following contributors:

harshraj8843
madhusgowda
anandfresh
RiteshK-611
vedantpople4
joao-vitor-souza
auleki
Jordan6794
bbhoom
shams-rf
deniss-eh
hemantsuteri
YaSh8202
parin23
krishan-here

Heart with ribbonBecome a SponsorHeart with ribbon

Become a sponsor and help us maintain and improve this project. Every contribution counts. Thank you!