/** * @title: power.cpp * @date: 2004.06.11 * @author: vinnie */ #include #include #ifdef __BORLANDC__ #pragma argsused #endif using namespace std; long power( int base, int exp) { long acc = 1; for ( ; exp; exp-- ) acc *= (long) base; return acc; } void main() { int base, exp; cout << "Raising a number to a power.\nInsert 2 numbers, \ first the base, Enter, then the Exponent: "; cin >> base; cout << "Good job! Now the Exponent: "; cin >> exp; cout << base << "^" << exp << " = " << power(base, exp) << '\n'; }