#include #include float compute1(float x) { fprintf(stdout, "\t... entering compute 1 ...\n"); return x * x * x + 27.0; } float power(float x) { fprintf(stdout, "\t... entering power ...\n"); return x * x * x; } float compute2(float x, float (*fct)(float)) { fprintf(stdout, "\t... entering compute 2 ...\n"); return (fct)(x); } int main(int argc, char** argv) { float x = 3; fprintf(stdout, "1. call the function directly: f(%f) = %f\n", x, compute1(x)); // declare a function pointer to compute1 here // float (*foo)(float); foo = &compute1; // call foo here // fprintf(stdout, "2. call compute1 using a function pointer: f(%f) = %f\n", x, foo(x)); // call foo here // fprintf(stdout, "3. call compute1 by passing a function pointer to compute2: f(%f) = %f\n", x, compute2(x, foo)); }