Electrical and Computer Engineering
2 of 24
UAH
CPE 112
Value-Returning Function Example
•int Power (/* in */ int x,     // Base number
•           /* in */ int n)    // Power to raise base to
•{
•   int result;   // Holds intermediate powers of x
•   result = 1;
•   while (n > 0)
•   {
•      result = result * x;
•      n--;
•   }
•   return result;
•}
•Usage
•   y = Power(5, 3)