60 658
Assignments Done
97,7%
Successfully Done
In April 2018

Answer to Question #8679 in C++ for niloofar

Question #8679
How can I write a program that calculates : e^x = 1+x/1!+x^2/2!+x^3/3!+...
Expert's answer
#include <iostream>
#include <cmath>
using namespace std;

void main(){

double x, r=1;

printf("Enter x value: ");
cin>>x;

for (int n=1;n<10;n++){
& int f = 1;
& for (int i=1;i<=n;i++) f = f*i;
& r += pow(x,n)/f;
}

printf("e^%f = %f\n", x, r);

}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be first!

Leave a comment

Ask Your question

Submit
Privacy policy Terms and Conditions