Header Ads

Learn Together, Stay Connected.

Determining the value of Exponential function-C++

#include<bits/stdc++.h>

using namespace std;

int main()
{
	double x,n;
	double fact=1.0,e=0.0;
	
	cin>>x>>n;
	int i;
	for(i=1;i<=n;i++)
	{
	
	fact=fact*i;
	e+=pow(x,i)/fact;
	
	}
	
	cout<<e<<endl;
	return 0;
}

No comments

Theme images by Dizzo. Powered by Blogger.