Answer to Question #98003 in C++ for Messie

Question #98003
Suppose an alien giant walks with decreasing steps (stride length). Each step is half of his last step. Write a function to calculate how far the alien giant can go with known steps if the giant's very step is one mile. Test your program with different numbers of steps to observe the results. With how many steps can the alien giant go more than two miles? Extra points will be given if you can find the result mathematically.
(Hint: Total distance = 1 + 1/2 + 1/4 + 1/8 + ...)
double walk(int steps)
{
double totalDistance;
//Fill in here

return totalDistance;
}

int main()
{
//Sample function calls. You might change the number of steps to test how far the giant can go
cout << "With 10 steps the giant walked " << walk(10) << " miles." << endl;
cout << "With 30 steps the giant walked " << walk(30) << " miles." << endl;
return 0:
}
1
Expert's answer
2019-11-04T15:55:33-0500
Dear Messie , 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