# Answer to Question #33171 in C++ for Sanjiv

Question #33171

write a program to find the sum of following series:- 1+x^2/3!+x^3/4!+x^4/5!+............+x^n/(n+1)!

Expert's answer

#include <iostream>

#include <conio.h>

#include <math.h>

using namespace std;

//find factorial

double factorial(long n){

if (n < 1)

return 0;

double product = 1;

for (int i = 1; i <= n; i++)

product *= i;

return product;//return result

}

//main function

int main()

{

double x;//variable for x

int sum=1;//variable for sum

cout<<"Enter x: ";//enter x

cin>>x;//read x

for(int i=2;i<1000;i++){

sum+=pow(x,i)/(factorial(i+2));//find sum

}

//show result

cout<<"Sum = "<<sum;

getch();//delay

return 0;

}

#include <conio.h>

#include <math.h>

using namespace std;

//find factorial

double factorial(long n){

if (n < 1)

return 0;

double product = 1;

for (int i = 1; i <= n; i++)

product *= i;

return product;//return result

}

//main function

int main()

{

double x;//variable for x

int sum=1;//variable for sum

cout<<"Enter x: ";//enter x

cin>>x;//read x

for(int i=2;i<1000;i++){

sum+=pow(x,i)/(factorial(i+2));//find sum

}

//show result

cout<<"Sum = "<<sum;

getch();//delay

return 0;

}

Need a fast expert's response?

Submit orderand get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

## Comments

## Leave a comment