I'm totally stuck with that, i don't know where to start.
I have to Integrate a function between a and b with n intervals in C.
I only have the function definition :
float funcintegrate(float (*f)(float x), float a, float b, int n);
I need to use the trapezoidal method.
EDIT :
Thanks all for you tips. I have now the answer !
Numerically integrate the function in the interval [a, b] using trapezoidal method (or rule) :
float funcintegrate(float (*f)(float x), float a, float b, int n);
int i;
double x;
double k = (b - a) / n;
double s = 0.5 * (f(a) + f(b));
for (i = 1; i < n; i++) {
x = a + k * i;
s = s + f(x);
}
return s * k;
}