一道C语言程序题

问题描述:

一道C语言程序题
e约定于1+1/2!+ 1/3!+.+1/n!
计算前20项;
计算各项,知道小于10^-4为止;

请楼主参考,希望有用
#include "stdio.h"
void main(void)
{
double value = 0;
double current = 1;
int i;
for(i=1; i 1e-4; i++)
{
current /= i;
value += current;
}
printf("when it's less than 1e-4, n = %d, value of E is %f\n", i-1, value);
}