Question #17737

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!

Expert's answer

#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");

}

#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");

}

## Comments

## Leave a comment