|
|
|
|
|
|
|
variable be a float variable. For each iteration of this loop, we compute the area of the corresponding rectangle and add this value to the total area under the curve. |
|
|
|
|
|
|
|
|
We want a value-returning function to compute the area of a rectangle, given the position of its left edge and its width. Let's also make X3 a separate function named Funct, so we can substitute other mathematical functions in its place without changing the rest of the design. Our program can then be converted quickly to find the area under the curve of any single-variable function. |
|
|
|
|
|
|
|
|
Get data
Set width = (high - low) / divisions
Set area = 0.0
Set leftEdge = low
FOR count going from 1 through divisions
Set area = area + RectArea(leftEdge, width)
Set leftEdge = leftEdge + width
Print area |
|
|
|
|
|
|
|
|
|
Figure 10-9
Area of the Second Rectangle |
|
|
|
|
|