Searching...

Code to calculate the sum of series 1/2!+2/3!+3/4!+4/5!+5/6!+ - - - -

15:20


#include <iostream>
using namespace std;
int main()
{
double fact,term,sum=0;
int length;
cout << "This program will disply the sum of following series... \n"<<endl;
cout << "1/2!+2/3!+3/4!+4/5!+5/6!+ - - - - - - \n"<<endl;
cout << "Enter Length of the series: ";
cin >> length;
for (int i=1;i<=length;i++)
{
fact=1;
for (int j=1;j<=i+1;j++)
{
fact=fact*j;
}
term=i/fact;
sum=sum+term;
}
cout << "Sum is: "<< sum << endl;
cout <<endl;

return 0;
}

0 comments:

Post a Comment

Thanks For Your FeedBack....

:) :)) ;(( :-) =)) ;( ;-( :d :-d @-) :p :o :>) (o) [-( :-? (p) :-s (m) 8-) :-t :-b b-( :-# =p~ $-) (b) (f) x-) (k) (h) (c) cheer
Click to see the code!
To insert emoticon you must added at least one space before the code.