// Mr. Minich // Wyo C++ // Ch. 9 Demo Program #11 // October 17, 2001 // Purpose - to illustrate a rounding function #include <iostream.h> #include <stdlib.h> // for rand and srand functions #include <time.h> // for time function int power(int myBase, int myExponent); void printName(); int getRandom(); int main() { int base = 0; // base for the exponentiation problem int exponent = 0; // exponent for the exponentiation problem int result = 0; // result of the exponentiation problem printName(); cout << "Enter a base: "; cin >> base; cout << "Enter an exponent: "; cin >> exponent; result = power(base, exponent); // two arguments are being passed to // the function power cout << "Result is " << result << endl; cout << getRandom() << endl; return 0; }// end of main int power(int myBase, int myExponent) { int i = 0; // local loop variable int finalAnswer = 1; // answer to exponentiation problem for (i = 1; i <= myExponent; i++) { finalAnswer = finalAnswer * myBase; } return finalAnswer; }// end of power void printName() { cout << "Mr. Minich" << endl; }// end of printName int getRandom() { int randomInteger = 0; srand(time(0)); // seeding rand function randomInteger = rand(); return randomInteger; }// end of getRandom