/*Write a program in C++ to display the sum of the series [ 1+x+x^2/2!+x^3/3!+....]. Sample Output: Input the value of x: 3 Input number of terms: 5 The sum is : 16.375 */ #include<iostream> #include<iomanip> #include<cmath> using namespace std; int main(){ int num,fact=1; double sum1=0.0,sum2=0.0,ans,x; cout<<"enter the value of x: "<<endl; cin>>x; cout<<"enter the value of terms: "<<endl; cin>>num; for(int i=1;i<=num-1;i++){ for(int j=1;j<=i;j++ ){ sum1=sum1+x; x=pow(x,i); fact = fact*i; sum2 = sum2+fact; } } ans = sum1/sum2; cout<<ans<<endl; return 0; }