Write a simple c++ program that computes the value of ex by using the formula: ex =1+x/1!+x2/2!+x3/3!+...+xN/N! try for N large N = 10000. using <iostream> and cmath of needed only. Solution #include <iostream> #include <cmath> using namespace std; int main(){ double n = 10000; double ex = 1; double x; cout << \"Enter the value of x: \"; cin >> x; double num = 1, den = 1, term = 1; for(double i = 1; i <= n; i++){ term *= (x / i); ex += term; } cout << \"e^\" << x << \" = \" << ex << \"\ \"; } .
Write a simple c++ program that computes the value of ex by using the formula: ex =1+x/1!+x2/2!+x3/3!+...+xN/N! try for N large N = 10000. using <iostream> and cmath of needed only. Solution #include <iostream> #include <cmath> using namespace std; int main(){ double n = 10000; double ex = 1; double x; cout << \"Enter the value of x: \"; cin >> x; double num = 1, den = 1, term = 1; for(double i = 1; i <= n; i++){ term *= (x / i); ex += term; } cout << \"e^\" << x << \" = \" << ex << \"\ \"; } .