```
#include <iostream>
#include <string>
using namespace std;
unsigned int pow(unsigned int a, unsigned int n);
int main()
{
string binary;
unsigned int decimal = 0;
cout << "Enter a binary number: ";
cin >> binary;
for(int i = binary.length()-1; i >= 0; i--) {
if(binary[i] > '1' || binary[i] < '0') {
cout << "Invalid binary number!" << endl;
return 1;
} else {
decimal += (binary[i] - '0') * pow(2, (binary.length()-i-1));
}
}
cout << "Decimal: " << decimal << endl;
return 0;
}
unsigned int pow(unsigned int a, unsigned int n)
{
unsigned int r = 1;
while( n-- > 0 ) r *= a;
return r;
}
```

The article starter has earned a lot of community kudos, and such articles offer a bounty for quality replies.