===========================================================================
CODING
#include<all.h>
void main()
{
clrscr();
double n=0,X=0,SUM=0,sum=1,q=1;
int i=1;
cout<<"\nEnter number: ";
cin>>n;
cout<<"\nEnter variable: ";
cin>>X;
cout<<"\n\n\n";
do
{
do
{
sum=i*sum;
q++;
}while(q<=i);
if(i%2==0)
{
cout<<" + ("<<X<<"^"<<i<<")/("<<i<<"!)";
SUM=pow(X,i)/sum+SUM;
}
else
{
cout<<" - ("<<X<<"^"<<i<<")/("<<i<<"!)";
SUM=-pow(X,i)/sum+SUM;
}
i++;
}while(i<=n);
cout<<" = "<<SUM;
getch();
}
CODING
#include<all.h>
void main()
{
clrscr();
double n=0,X=0,SUM=0,sum=1,q=1;
int i=1;
cout<<"\nEnter number: ";
cin>>n;
cout<<"\nEnter variable: ";
cin>>X;
cout<<"\n\n\n";
do
{
do
{
sum=i*sum;
q++;
}while(q<=i);
if(i%2==0)
{
cout<<" + ("<<X<<"^"<<i<<")/("<<i<<"!)";
SUM=pow(X,i)/sum+SUM;
}
else
{
cout<<" - ("<<X<<"^"<<i<<")/("<<i<<"!)";
SUM=-pow(X,i)/sum+SUM;
}
i++;
}while(i<=n);
cout<<" = "<<SUM;
getch();
}
===========================================================================
No comments:
Post a Comment