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
int main()
{
int n;
double radius = 2;
double width = radius / n;
cout << "Enter the number of rectangles> ";
cin >> n;
then height would be h = square root of( r * r – x * x) but I'm not sure how to implement that into my program. then the area would be the sum of n (h*w).
does anyone know how i would be able to set up the height of the rectangles?