1. ## Function Question

in this simple example of a function, the author of the book explains quite a bit on it. maybe a little too much so i got a little confused. i understand that the first part (test function, return 0 ) defines the way this function will output results on the screen, and the second part introduses the formula and values for the function to work with. am i anywhere near the ballpark, or did i end up in a museum ?

#include <stdio.h>
/* test power function */
int power(int m, int n);
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;
}

2. The 'main' function prints 10 lines to the screen.

Each line prints out three things:
1) the value of I
2) the value of 2 raised to the I power.
3) the value of -3 raised to the I power.

The 'pow' function actually does the work of raising the base to whatever power your pass it.

Quzah.