Answer to Question #102660 in C++ for Kajal jain

Question #102660
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
2020-02-09T09:31:07-0500
Dear Kajal jain, 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