#include <stdio.h>
#include <math.h>
double integrate (double (*)(double), double, double);
![](imgs/spacer.gif)
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;
}
![](imgs/spacer.gif)
void initial (int x, char* y) {
printf ("fewer than %d chars in %s\n", x, y);
}
void main (void) {
double (*fptr)();
/* want a pointer to a function not */
void (*funptr)(); /*a function that returns a pointer */
|
![](imgs/spacer.gif) |
|
fptr = cos;
fprintf (stdout, "Cosine integral is %f\n",
integrate ((*fptr), 0.0, 1.1));
|
![](imgs/spacer.gif) |