#include<stdio.h>
#include<math.h>
int main(void)
{
double e,pi;
double funpi(double e);
printf("Enter e:");
scanf("%lf",&e);
pi=funpi(e);
printf("pi=%f
",pi);
return 0;
}
double funpi(double e)
{
int denominator,flag;
double item,sum;
flag=1;
denominator=1;
item=1.0;
sum=0;
while(fabs(item)>=e){
item=flag*1.0/denominator;
sum=sum+item;
flag=-flag;
denominator=denominator+2;
}
return sum*4;
}