60 635
Assignments Done
97,8%
Successfully Done
In April 2018

Answer to Question #43137 in C++ for sanoop lal

Question #43137
1 - u + u^3/2! - u^5/3! + ... + (-1)^(2n-1) u^(2n-1)/n!
Expert's answer
#include <iostream>
#include <math.h>
#include <conio.h>
using namespace std;
int main(){
int n;
double u;
cout<<"n = ";
cin>>n;
cout<<"u = ";
cin>>u;
double sum = 1.0;
double value = u;
for (int i = 1; i <= n; ){
  sum += pow(-1.0, (double)i)*value;
  value *= u*u/(++i);
}  
cout<<"answer = "<<sum<<endl;
getch();
return 0;

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!

Comments

No comments. Be first!

Leave a comment

Ask Your question

Submit
Privacy policy Terms and Conditions