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;
}