I'm new to C++ and here's a simple assignment. I'm not sure how to pull this off... ANY help will be appreciated . Here's the code for the assignment...

You have to implement a function called approachPi that takes no parameters, and has the return type double. This function returns the next element of a series, i.e. on the first call of the first element is returned, on the second call the second element is returned and so forth. The specific series that your function must use is the Gregory series (Difficult to write the formula here). I attached the formula.

This means on the first call to the function e1 = 4 will be returned, on second call e2 = 4(1 + -1/3) will be returned, and so on. This goes into infinity.

** The main file **

```
#include <iostream>
#include "Functions.h"
using namespace std;
int main()
{
for(int i=0;i<3;++i)
cout<<"Step "<<i+1<<":"<<approachPi()<<endl;
return 0;
}
```

** The Functions.h file **

```
#ifndef FUN
#define FUN
double approachPi();
#endif
```

** My Functions.C file **

```
#include <iostream>
#include <cmath>
#include "Functions.h"
using namespace std;
double approachPi()
{
double num;
double sum;
int size;
for(int k = 1; k < size; k++)
{
cout << "Please enter a number: ";
cin >> num;
sum = num * pow(-1,(k+1))/((2*k)-1);
cout << sum << endl;
}
return sum;
}
```

** Makefile **

```
main: Functions.o Prac1t1.o
g++ -static Prac1t1.o Functions.o -o main
Prac1t1.o : Prac1t1.C
g++ -c Prac1t1.C
Functions.o : Functions.C
g++ -c Functions.C
```