Compile errors/ programming errors

Heres the code... Problems encountered are listed at the bottom ...thank you.


#include <iostream>
#include <iomanip>
#include <cmath>

using namespace std;


int main()

{

int sum = 0; // sum
int w = 0; // width
int r = 0; // radius
int y = 0; // height
int n = 0;
int a = 0; //area
double pow = 0; // power
double sqr = 0;


cout << "Circle Radius: \n";
cin >> r;
cout << "Exact Area: \n";
cin >> a;
cout << "Area with 100 rectangles: \n";
cout << "Difference from the exact area: ";
cout << "Approximate using 1000 rectangles: \n";
cout << "Difference from the exact area: ";
cout << "Approximate using 10000 rectangles: \n";
cout << "Difference from the exact area: ";
cout << "Approximate using 100000 rectangles: \n";
cout << "Difference from the exact area: ";





w * sqr(pow(r - w)); //area of the first rectangle
w * sqr (pow(r - 2 * w));//area of the second rectangle
w * sqr (pow(r - 3 * w));//area of the third rectangle



// here begins the algorithm to calculate pi

start: n=0; y=sqr(2)-1; a=6-4*sqr(2);
repeat: {n=n+1; y=(1-sqr(sqr(1-y^4)))/(1+sqr(sqr(1-y^4)));
a=(a*(1+y)^4)-y*(1+y+y^2)*2^(2*n+3)};







system ("PAUSE");
return 0;


}


Im new to C++ and Im not sure what to do here. The program errors say I cannot use pow or sqr as a function. Any help would be awesome.
1
2
double pow = 0;
double sqr = 0; 


So pow is a double, and sqr is a double. They're just two numbers. What exactly do you intend by saying
w * sqr(pow(r - w));
given that sqr and pow are just two numbers? What's supposed to happen there?

repeat: What's that meant to do?
start: Likeiwise.

^ That means XOR, as in the Exclusive-Or operator. Is that what you meant?

I think you need to go back and restart on C++ syntax.
Last edited on
The program must allow the user to investigate an indefinite number of circles without having to restart each time. How do I use the loop in main()??
The user also needs to be prompted to enter a radius.
The program needs to approximate the area of a circle using the method called running sum technique.
Im tring to use the pow() function to computer the square of the value instead of multiplying the valueby itself.
There needs to be 5 calculations.
1. The exact area, using 3.141592653598979 (use all digits for accuracy)
2. Approx area using 100 rectangles
3. Approx area using 1000 rectangles
4. Approx area using 10000 rectangles
5. Approx area using 100000 rectangles
How do I use the loop in main()??

1
2
3
4
5
6
7
8
int main()
{
  bool keepGoing = true;
  while (keepGoing)
  {
     // lots of code here, including a decision to set keepGoing to flase when appropriate
  }
}
Topic archived. No new replies allowed.