63 132
Assignments Done
99,1%
Successfully Done
In July 2018

Answer to Question #4287 in C++ for kuldeep

Question #4287
Write a c++ program to sum the sequence
1+ 1/1! + 1/2! + 1/3! + .......
Expert's answer

#include <iostream>
using namespace std;
void main(){
double s = 0;& //that is the sum
double factorial = 1;& //it's the denominator
int i = 1;
cout<<"factorial = "<<factorial<<"\r\n";
for (i=1;i<=10;i++) {& //10 cycles is enough, we'll get 1.71828 at the eighth step
factorial = i*factorial;
s = s + 1/factorial;
cout<<"s = "<<s<<"\r\n";
}
}

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