ex2-4.cpp - Example 2-4 Default Arguments

// File:  ex2-4.cpp

#include <iostream>
using namespace std;

long power(int,int = 2);

int main(void)
{
	cout << power(5) << endl;
	cout << power(2,10) << endl;
	cout << power(12345) << endl;
	return 0;
}


long power(int x, int y)
{
	long num = 1;
	for (int i = 1; i <= y; i++) num *= x;
	return num;
}



CIS27: Programming in C++    Instructor: Joe Bentley