You have a fence that is to be 100 meters long. Your fence posts are to be placed every 10 feet. How many fence posts do you need? Why is the presence of this problem in a programming book not as silly as it might seem?What problem that programmers have does this question address?
Given data:
A fence that is to be 100 meters long and fence posts are to be placed every 10 feet.
Off-by-one errors abound in problem solving, not just writing loops.
General reasoning from those who do not think carefully = 100 feet of fence/10 feet between posts
=10 posts.
So, it will leave the last 10 feet of fence without a post.
You need 11 posts to provide 10 between-the-post 10-foot intervals to get 100 feet of fence.