My photo
Bangalore, Karnataka, India
Extending one hand to help someone has more value rather than joining two hands for prayer

Archives

evalute x+pow(x,2)/2!+pow(x,4)/4!+_______ pow(x,n)/n!

Tuesday, September 1, 2009

#include<iostream.h>
#include<conio.h>
#include<math.h>
void main()
{
  clrscr();
  int x,n;
  float sum=0;
  cout<<"enter the value of x and n respectively: ";
  cin>>x>>n;
  for(int i=2;i<=n;i+=2)
  {
    int l,f=1;
    float m;
    for(l=1;l<=i;l++)
    f*=l;
    m=pow(x,i)/f;
    sum=sum+m;
    }
    sum+=x;
    cout<<"result of the exp is: "<<sum;
    getch();
    }

0 comments: