#include <iostream>
#include <math.h>
using namespace std;

int main() {
    cout << "Enter Binary Number : " ;
    int n;
    cin >> n;
    cout << endl;
    
    int res = 0, i = 0;
    while(n != 0){
        int bit = n % 10;
        res += pow(2,i) * bit;
        n = n/10;
        i++;
    }
    cout << "Decimal is : " << res << endl;
}

Embed on website

To embed this project on your website, copy the following code and paste it into your website's HTML: