include stdio include stdlib int main double int double 00001 double p

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
#include <stdio.h>
#include <stdlib.h>
int main() {
double x;
int n=1;
double e=0.00001;
double prev_f, f=0, fact=1;
printf("Input x: ");
scanf("%lf",&x);
do{
fact*=x;
prev_f=f;
f+=(2*n)/((2*n-1)*fact);
n++;
}while(prev_f==0||(1-f/prev_f)>e);
printf("f=%lf \n",f);
system("PAUSE");
return 0;
}