// con1.cpp : Defines the entry point for the console application. // #include "stdafx.h" #include using namespace std; int main() { int inputNum, digit, _8ToThePower_i = 1, decimalEquiv = 0; int digitErrorFlag = 0; cout << "Enter an integer number in base 8:"; cin >> inputNum; while (inputNum > 0) { digit = inputNum % 10; inputNum /= 10; cout << digit << " : "; if (digit >= 8) { cout << "Error! There's an invalid digit " << digit << endl; digitErrorFlag = 1; break; } cout << " 8^i = " << _8ToThePower_i; int ithTerm = _8ToThePower_i * digit; cout << " ith term = " << ithTerm << endl; _8ToThePower_i *= 8; decimalEquiv += ithTerm; } if (digitErrorFlag == 0) cout << "The decimal equivalent is : " << decimalEquiv << endl; return 0; }