write a c program the computes the value ex by using the
formula
e^x=1+x/1!+xsquare/2!+xcube/3!+....
//chap 4.35(c)
#include <iostream>
using namespace std;
int main()
{
while (true) {
int x;
long n=30;
double factorial = 1;
double e=1.0;
cout<<"請輸入一個整數x\n";
cin>>x;
if (x>=0){
for(int i=1;i<=n;i++)
{
factorial = i * factorial;
e += x/factorial;
x=x*x;
}
}
cout<<"e^x的值為:"<<e<<endl;
}
return 0;}
可以編譯,但出來的數值不太對