C++ Program – Sum of series using “for” loop

by Nideesh C on May 2, 2011 · 0 comments

in C++




//Downloaded From theonlinetutorials.com
//(C)2011.All rights reserved.
//SUM OF SERIES 1-x/1! + x3/2!....
#include<iostream.h>
#include<conio.h>
#include<math.h>
void main()
{
clrscr();
int f=1,h,j,k=1,i,n,x;
float s=0;
cout<<"Enter the numerator and limit"<<endl;
cin>>x>>n;
 for(i=1;i<((2*n)-1);i=i+2)
 {
 f=1;
 for(j=1;j<=(i+1)/2;j++)
 {
 f=f*j;
 }
 s=(s+((pow(x,i) * pow(-1,k))/f));
 k++;
 }
cout<<"Result  "<<s+1;
getch();
}



Not Satisfied ? Just search & get the result

Related Posts Plugin for WordPress, Blogger...
Be Sociable, Share!

Related posts:

  1. C++ Program – Square of Nos
  2. C Program To find the sum of the cos series
  3. C++ program – No of Digits in a number (Using while loop)
  4. C++ Program – Sum of Prime nos
  5. C++ Program – Sum of Odd Even nos

Leave a Comment

Previous post:

Next post: