Answer

Our function should take the two limits of integration and the number of intervals as arguments. It should return the approximation to the area under integrand as its result.

float trapezoid (float a, float b, int N)

Notice that everything is a floating-point number except for the number of subintervals, which is an integer.

Return to lesson.



Christopher R. Johnson
Hamlet Project
Department of Computer Science
University of Utah