#include #include void initial (int, char*); double integrate (double (*)(double), double, double); double integrate (double (*fptr)(double), double a, double b) { double x, sum = 0.0, delta_x = 0.1; for (x = a; x <= b; x = x + delta_x) sum = sum + delta_x * (*fptr)(x); return sum; } void initial (int x, char* y) { printf ("fewer than %d chars in %s\n", x, y); } int main (void) { double (*fptr)(); /* want a pointer to a function not */ void (*funptr)(); /*a function that returns a pointer */ funptr = initial; initial (64, "Help me, please?") ; (*funptr) (24, "Why, Oh why?") ; /* next example*/ fprintf (stdout, "Integral of sine is %f\n", integrate (sin, 0.0, 1.1)); fptr = cos; fprintf (stdout, "Cosine integral is %f\n", integrate ((*fptr), 0.0, 1.1)); return 0; } /* fewer than 64 chars in Help me, please? fewer than 24 chars in Why, Oh why? Integral of sine is 0.590509 Cosine integral is 0.963144 */