Wednesday 5 June 2013


//function to construct exponential series of user defined "n". if user enter n=10 then it construct series upto 10...
// exponential series

#include <iostream.h>
#include <math.h>

void main()
{
int terms;
float f = 1, x, v = 0;

cout<<"enter value of variable x: ";
cin>>x;
cout<<"enter number of terms of series: ";
cin>>terms;

for(int n = 1; n<=terms ; n++)
{
v = v + pow(x, n-1)/f;
f = f*n;
}
cout<<"e^"<<x<<" upto "<<terms<<" terms is = "<<v<<endl;
cout<<endl;
}

0 comments:

Post a Comment

Subscribe to RSS Feed Follow me on Twitter!