#include <stdio.h>

int power(int m, int n);

/* 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;
}

/* 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;
}

/*
Discuss:

- functions (encapsulate computations, use without worry about implem.)
- function declaration (function prototype), definition
- parameter vs. argument (formal argument/actual argument)
- arguments, call by value
- local variables
- call by reference using pointers (later), arrays are call by reference

  change power:
    int p;
    for (p=1; n>0; --n)
        p = p * base;
    return p;


Exercise 1-15 (page 27)

*/