➽ Program:-

#include<iostream>

using namespace std;

int main()

{     

    int  number, binary_value, decimal_value = 0, base = 1, rem;

    cout << "Enter a Binary Number(In 0s and 1s): ";

    cin >> number;

    binary_value = number;

 

    while(number > 0)

    {

        rem = number % 10;

        decimal_value += rem * base;

        number = number / 10 ;

        base = base * 2;

    }

 

    cout << "Decimal Equivalent of " << binary_value << " is " << decimal_value;

    return 0;

}

➽ Output:-

Enter a Binary Number(In 0s and 1s): 10111001
Decimal Equivalent of 10111001 is 185