help w/ problem

I've been working on this now for a couple of weeks and am still having dificulties. I'm trying to come up with a function to compute and return the area of the quarter circle by dividing it into a given number of rectangles. I need to have it accept the number of rectangles used, and display the estimate of pi.

The width of each rectangle can be achieved by dividing the radius by the # of rectangles... so I got

I've been working on this now for a couple of weeks and am still having dificulties. I'm trying to come up with a function to compute and return the area of the quarter circle by dividing it into a given number of rectangles. I need to have it accept the number of rectangles used, and display the estimate of pi.

The width of each rectangle can be achieved by dividing the radius by the # of rectangles... so I got

Thanks peeps, but i still do not understand how to get the height. eg, with radius 2 and n 10, the width of each rectangle would be 0.2. therefore x would be changing at the midpoint of each rectangle. so x=0.1, 0.3, 0.5, etc up to the 10th rectangle.....I have no idea how to get my program to do that:(

Don't see the problem. As you say, the width of each rectangle will be r/n, and presumably you will be going round a loop to calculate the area of each rectangle. If i is the index in a for loop, then at each iteration x = r * i / n, and the height will be sqrt( r * r - r * r * i * i / (n * n) ), or slightly more compactly, r * sqrt( 1 - i * i / (n * n) ).