Question: C++ Programming a) Write a program that computes the value of e x by using the formula e x = 1 + x / 1!
C++ Programming
a) Write a program that computes the value of e x by using the formula
e x = 1 + x / 1! + x2 / 2! + x3/ 3! + ...
Prompt the user for the desired accuracy of e ( the number of terms in the summation).
this is what I did so far:
#include
int main() { double factorial = 1; int i=1; int x; double e = 1; int n;
cout << "Enter number of terms: "; cin >> n; cout << "Enter number power: "; cin >> x;
for (i = 1; i <= n; i++) { factorial*= i; e = e + (pow (x,i)) / factorial;
cout << " " << factorial << endl;
cout << "The value of e^x: " << e << endl; } }
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
