Write a program in C++ having function sum sequence having two value parameters ‘u’ and ‘n’ with result type float .To find the sum of series given below:-
1-U+U^2/2!-U^3/3!+U^4/4!-……………………………………………………………..±U^n/n!
#include <math.h>
#include <iostream>
using namespace std;
int factorial(int n) {
return !n ? 1 : n * factorial(n - 1);
& }
int main()
{
double s=0,a,z,x;
int u,n,i,j=0;
cout<<"enter u:";
cin>>u;
cout<<"enter n:";
cin>>n;
for(i=0;i<n;i++){
z=factorial(i);
cout<<"\n"<<z;
x=i/z;
cout<<"\n"<<x;
a=& pow(-1,i)*pow(u,x);
cout<<"\n"<<a;
s+=a;}
&
cout<<"\nS=& "<<s;
cout<<"\n\n";
system("PAUSE");
}
Need a fast expert's response?
Submit order
and get a quick answer at the best price
for any assignment or question with DETAILED EXPLANATIONS!
Learn more about our help with Assignments:
C++