Program to find the Sum of Series | C++ Programming

Program to find the Sum of Series | C++ Programming
//Program to find the Sum of Series
#include<iostream.h>
#include<stdio.h>
#include<conio.h>
void main()
{clrscr();
float x,sum,term,fact=1;
int i,n;
cout<<"\n enter the value of x and n:";
cin>>x>>n;
sum=1;term=1;
for(i=1;i<=n;i++)
{fact=fact*i;
term=term+(x/fact);
sum=sum+term;
}cout<<"\n sum of the series="<<sum;
getch();
}
Or
#include <iostream.h>
#include <conio.h>
#include <math.h>
void main()
{clrscr();
  long x,n,i,sum=0,term;
  cout<<"\n enter the x:";
  cin>>x;
  cout<<"\n enter the n:";
  cin>>n;
for(i=1;i<=n;i++)
 {
  term=pow(x,i);
  sum=sum+term;
 }
  cout<<"\n enter the sum="<<sum;
 getch();

 }
Program to find the Sum of Series | C++ Programming Program to find the Sum of Series | C++ Programming Reviewed by SHERE KHOJRAHA on February 13, 2019 Rating: 5

No comments:

Powered by Blogger.