Electrical and Computer Engineering
11 of 14
UAH
CPE 112
Problem-Solving Case Study:
Finding the Area Under a Curve
•float Funct( float );
•void  GetData( float&, float&, int& );
•float RectArea( float, float );
•int main()
•{
•    float low; float high; float width; float leftEdge;
• float area; int divisions; int   count;
•     
• GetData(low, high, divisions);
•    width = (high - low) / float(divisions);
•    area = 0.0; leftEdge = low;
•    for (count = 1; count <= divisions; count++)
•    { 
•        area = area + RectArea(leftEdge, width);
•        leftEdge = leftEdge + width;
•    }
•    cout << "The result is equal to "
•         << setprecision(7) << area << endl;
•}
•