/* functionpointer.c - We see how to use pointers to functions.
 */

#include <stdio.h>

typedef int (*f)(int x); //f is the type for pointer to functions of one integer
	// argument that return an integer

int square(int x) { return x*x; }

int cube(int x) { return x*x*x; }

int main() {
    f a[2] = {square, cube};
    int k, j;
    for (k = 1; k < 10; k++) {
	for (j = 0; j < 2; j++)
	    printf("%8d", a[j](k));
	printf("\n");
    }
    return 0;
}

