Hello everyone,

I was given this assignment, but I am stuck. Your help is appreciated :)

1.Ask for a desired accuracy epsilon for the to approximate value of \pi.

2. Use the Leibniz series to approximate pi.

3.Check after each iteration step wether the value of the last summand | \frac{(-1)^n}{2n+1} | is smaller then the desired accuracy \epsilon and the iteration can end.

4.Print your approximation of \pi ( the Leibniz series will calculate \frac{\pi}{4} and not pi directly).

5. Only use basic arithmetic operations and define all floating point variables with data type double. Using the predefined function pow is not allowed!

```
#include <stdio.h>
int main ()
{
int x;
double sum=0;
double PI,eps;
int i;
printf("Please Input the desired accuracy eps: ");
scanf("%d", &eps);
for (i=1; i<x; i++)
{
if ((i%2)==1)
sum=sum+1.0/((2.0 * (double)i) - 1.0);
else
sum = sum - 1.0/((2.0 * (double)i) - 1.0);
}
PI= 4*sum;
printf("The sum is %f\n",sum);
printf("Approximate value of PI is %9.f\n", sum);
return 0;
}
```