SLIDE1

Sunday, December 28, 2014

tính số e - bài tập lập trình c

viết chương trình c tính số e và lũy thừa cơ số e

//tính số e, lũy thừa với số e
#include<stdio.h>
#include<conio.h>
#include<math.h>
double e(double x)
{
double tong = 1, i = 1, ps = 1;
while (ps > 0.00001)
{
ps = ps*x / i;
tong += ps;
i++;
}
return tong;
}
void main()
{
printf("e^1=%lf\ne^7=%lf\n", e(1),e(7));
}