#include<iostream.h>
#include<conio.h>
#include<math.h>
long facto(int);
void main()
{
clrscr();
int num,n;
int i=0;
long j=0;
int sum=0;
cout<<"The series is:";
cout<<"x/1!+x^2/2!+x^3/3!+............................";
cout<<endl<<"Enter the number upto which you want the sum:";
cin>>n;
cout<<endl<<"The value of x:";
cin>>num;
for(i=1;i<=n;i++)
{
j=facto(i);
sum=sum+pow(num,i)/j;
}
cout<<endl<<"The sum of the series is:"<<sum;
getch();
}
long facto(int g)
{
int k=1;
while(g>0)
{
k=k*g;
g--;
}
}
#include<iostream.h>
#include<conio.h>
#include<math.h>
long facto(int);
void main()
{
clrscr();
int num,n;
int i=0;
long j=0;
int sum=0;
cout<<"The series is:";
cout<<"x/1!-x^2/2!+x^3/3!-............................";
cout<<endl<<"Enter the number upto which you want the sum:";
cin>>n;
cout<<endl<<"The value of x:";
cin>>num;
for(i=1;i<=n;i++)
{
j=facto(i);
if(i%2==0)
sum=sum-pow(num,i)/j;
else
sum=sum+pow(num,i)/j;
}
cout<<endl<<"The sum of the series is:"<<sum;
getch();
}
long facto(int g)
{
int k=1;
while(g>0)
{
k=k*g;
g--;
}
}
#include<conio.h>
#include<math.h>
long facto(int);
void main()
{
clrscr();
int num,n;
int i=0;
long j=0;
int sum=0;
cout<<"The series is:";
cout<<"x/1!+x^2/2!+x^3/3!+............................";
cout<<endl<<"Enter the number upto which you want the sum:";
cin>>n;
cout<<endl<<"The value of x:";
cin>>num;
for(i=1;i<=n;i++)
{
j=facto(i);
sum=sum+pow(num,i)/j;
}
cout<<endl<<"The sum of the series is:"<<sum;
getch();
}
long facto(int g)
{
int k=1;
while(g>0)
{
k=k*g;
g--;
}
}
#include<iostream.h>
#include<conio.h>
#include<math.h>
long facto(int);
void main()
{
clrscr();
int num,n;
int i=0;
long j=0;
int sum=0;
cout<<"The series is:";
cout<<"x/1!-x^2/2!+x^3/3!-............................";
cout<<endl<<"Enter the number upto which you want the sum:";
cin>>n;
cout<<endl<<"The value of x:";
cin>>num;
for(i=1;i<=n;i++)
{
j=facto(i);
if(i%2==0)
sum=sum-pow(num,i)/j;
else
sum=sum+pow(num,i)/j;
}
cout<<endl<<"The sum of the series is:"<<sum;
getch();
}
long facto(int g)
{
int k=1;
while(g>0)
{
k=k*g;
g--;
}
}
No comments:
Post a Comment