#include <stdio.h>

int power(int m, int n);	/* function prototype */

int power_v2(int m, int n);	/* function prototype */


/* test power function */

main()
{
	int i;

	for (i = 0; i < 10; ++i)
	   printf("%d %d %d\n", i, power(2,i), power(-3,i));
	return 0;	/* 0 implies normal termination */
}


/* power: raise base to n-th power; n >= 0 */

int power(int base, int n)	
{
	int i, p;

	p = 1;
	for (i = 1; i <= n; ++i)
	   p = p * base;
	return p;
}



/*

 * Parameter (formal argument): a variable named in the parenthesized list in a function.

 * Argument (actual argument): the value used in a call of the function.

 */


/* power: raise base to n-th power; n >= 0; version 2 */

int power_v2(int base, int n)
{
	int p;

	for (p = 1; n > 0; --n)		/* n is a temp var, call by value */
	   p = p * base;
	return p;
}




