
If n is 123, count will end up as 3, which would be correct. There are three

digits. If n is 100, count will end up as 2, which is not the correct number of

digits. The loop condition should actually be. While temp is greater than or

equal to 10. We can see this by hand tracing the code. The values I'm

interested in are count and temp. If n starts out as 123, then count will start

as 1, temp will start as 123. Temp is greater than 10, so we increment count.

And divide temp by 10 and divide temp by 10.0 which will give us 12.3. Now, we

go back to the loop condition. Temp is still greater then 10 so we increment

the count and then divide temp by 10.0 again so we have 1.23. Now, when we

check again, temp is less than 10. So we skip to the end, and we're done. But

what would happen if n was 100? Count would start as 1, the way it did before.

And temp would start as 100. Temp is greater than 10, so we would increment

count and then divide temp by 10.0. So we would have 10. And then check the

condition again. But this time, 10 is not greater than 10. It's equal, so it

skips out immediately. When in fact, we still had two digits left. We needed to

increment count again. This is why the condition should be temp is greater than

or equal to 10.