Answer to Question #32717 in C++ for Sanjiv

Question #32717
write a program to find the sum of following series:-

1+x/1!+x^3/2!+x^5/3!+............+x^(2n-1)/n!
1
Expert's answer
2013-07-12T08:10:18-0400
#include <iostream>
#include <conio.h>
using namespace std;

double factorial(long n){
if (n < 1)
return 0;
double product = 1;
for (int i = 1; i <= n; i++)
product *= i;
return product;
}
//main function
int main()
{
double x;
double sum=1;
cout<<"Enter x = ";//input x
cin>>x;//read x
//calculate sum
for(int n=1;n<10;n++){
sum+=pow(x,(2*n-1))/factorial(n);
}
//show result
cout<<"Sum="<<sum;
getch();//delay
return 0;
}

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 the first!

Leave a comment

LATEST TUTORIALS
APPROVED BY CLIENTS