This C++ Program converts the given binary number into decimal. The program reads the binary number, does a modulo operation to get the remainder, multiples the total by base 2 and adds the modulo and repeats the steps.

Here is source code of the C++ program which converts the given binary number into decimal. The C++ program is successfully compiled and run on a Linux system. The program output is also shown below.

`/*`

`* C++ program to convert binary number into decimal`

`*/`

`#include<iostream>`

`using namespace std;`

int main()

`{`

long bin, dec = 0, rem, num, base = 1;

cout << "Enter the binary number(1s and 0s) : ";

cin >> num;

bin = num;

while (num > 0)

`{`

rem = num % 10;

dec = dec + rem * base;

base = base * 2;

num = num / 10;

`}`

cout << "The decimal equivalent of " << bin << " : " << dec << endl;

return 0;

`}`

$ g++ main.cpp $ ./a.out Enter the binary number(1s and 0s) : 10000000000 The decimal equivalent of 10000000000 : 1024

**Sanfoundry Global Education & Learning Series – 1000 C++ Programs.**

If you wish to look at all C++ Programming examples, go to C++ Programs.

**If you liked this C++ Program, kindly share, recommend or like below!**