Answer to Question #93042 in C++ for Ganesh

Question #93042
Consider the code below for calculating the value of e (Euler's number/constant used in mathematics). It solves the same problem as discussed in the lecture but it does it differently. In the ith iteration it calculates the value of 1/i! and adds it to the result.

main_program{
int n; cin >> n;

double result = 0;
int i=__;

repeat(n){
// calculate 1/i!
int t=1;
double term = 1;
repeat(i){
term = term/t;
t = t + 1;
}
result = result + term;
i = i + 1;
}
cout << result << endl;

}

What should i be initialized to?

How many division operations does the above code do for n=10?

How many division operations did the code discussed in the lecture do for n=10?
1
Expert's answer
2019-08-21T09:55:39-0400
Dear Ganesh, your question requires a lot of work, which neither of our experts is ready to perform for free. We advise you to convert it to a fully qualified order and we will try to help you. Please click the link below to proceed: Submit order

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 the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS