#include <iostream>
#include <cmath>
using namespace std;
int main() {
long long binaryNumber;
cin >> binaryNumber;
long long decimalNumber = 0;
int power = 0;
while (binaryNumber != 0) {
int digit = binaryNumber % 10;
decimalNumber += digit * pow(2, power);
binaryNumber /= 10;
power++;
}
cout << "Decimal: " << decimalNumber << endl;
return 0;
}
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter