RSS

SERIES 3

28 Jun

/* THIS PROGRAM CREATES A FUNCTION TO FIND THE SUM OF THE FOLLOWING SERIES
Y + Y ^3/2! + Y^5 /3! + … + Y^(2m-1)/m!  */

#include <iostream.h>
#include <conio.h>
#include <math.h>

double sumseries(int,int);

void main()
{
clrscr();
int y,m;
cout<<“Enter the Value of ‘Y’\n”;
cin>>y;
cout<<“\nEnter the number of terms\n”;
cin>>m;
double sum = sumseries(y,m);
cout<<“\nThe sum of the series is \n”<<sum;
getch();
}

double sumseries(int y, int m)
{
double sum = 0.0;

for(int i=1; i<=m; i++)
{
int val = 1;
int k =i;
while(k>0)
{
val *= k;
k–;
}
sum += pow(y,i)/val;
}

return sum;
}

Advertisements
 
Leave a comment

Posted by on June 28, 2015 in Series

 

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

w

Connecting to %s

 
%d bloggers like this: