I am having a problem with my program. My teacher said I was very close to get the correct answer but for some reason, I can not seem to figure out what is wrong with it. The program calculates the area of a circle. n is the number of rectangles, that get smaller and smaller throughout the program until the difference between the old calculated value and the new value is less than .1%. X is the length of the base of each rectangle. If the difference is bigger than .1%, the loop should repeat itself with a higher number for N. He told me that I should use another while loop instead of the for loop that I am using right now.
I really hope that someone can help me, and thank you for your help already.
/* This program calculates the area under a semi circle, by prompting the user to enter a vlaue for the radius.*/
#include<iostream>
#include<cmath>
using namespace std;
int main ()
{
double radius, difference, area, oldarea, fullarea, n(2), i, square;
cout << "Please enter the radius of the circle you wish to calcuate the area for.\n\n";
Tell me, the very first time you reach the while loop, what is the value of difference? You're testing against it, so what are you expecting to happen the very first time?
The first time I reach it, it should use the value from "old area" which is an estimate that is made before the while loop and when it gets in the loop it should use this value and use the new value to calculate the difference...