Answer to Question #8679 in C++ for niloofar
How can I write a program that calculates : e^x = 1+x/1!+x^2/2!+x^3/3!+...
1
2012-04-24T09:51:53-0400
#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!
Learn more about our help with Assignments:
C++
Comments
Leave a comment