Please help me solve problem c this use C and also I can run

Please help me solve problem c this use C++ and also I can run it(I already did a&b)
(Factorial) The factorial of nonnegative integer n is written n! (pronounced \"n factorial\" and is defined as follows: factorialry. n! n (n-1) (n -2) 1 (for values of n greater than 1) and For example, 5! 5. 4. 3.2. 1, which is 120. Use while statements in each of the following: a) Write a program that reads a nonnegative integer and computes and prints its factorial. b) Write a program that estimates the value of the mathematical constant e by using the formula Prompt the user for the desired accuracy of e (i.e., the number of terms in the summation). c) Write a program that computes the value of ex by using the formula. X X X Prompt the user for the desired accuracy ofe (i.e., the number of terms in the summation).

Solution

#include <iostream>

using namespace std;

int main()
{
cout << \"this program compute e as e = 1 +1/1! + 1/2! + 1/3!+...\" << endl;
cout <<endl;
cout << \"Enter number of terms to be used for finding e: \";
int nTerms;
cin >> nTerms;

long fact = 1;

double e = 1;

if (nTerms == 1) {
cout << \"1\ \";
return 0;
}

for (int i = 1; i < nTerms; i++)
{
fact = fact*i;
e += (1.0/fact);
}

cout << \"Value of e is : \" << e << endl;

return 1;
}

Please help me solve problem c this use C++ and also I can run it(I already did a&b) (Factorial) The factorial of nonnegative integer n is written n! (prono

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site