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 #include using namespace std;

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

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!