Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things
 
PerlMonks  

Re: Not understanding while loop counting

by davido (Cardinal)
on Aug 10, 2020 at 14:59 UTC ( #11120546=note: print w/replies, xml ) Need Help??


in reply to Not understanding while loop counting

Consider the steps

  • Set count to zero.
  • Check if count is less than ten. It is zero.
  • Increment count to one.
  • print count (1)
  • Do this a few more times........then...
  • Check if count is less than ten. It is nine.
  • Increment count to ten.
  • Print count (10)
  • Check if count is less than ten (it is 10, so it is not less)
  • Do not enter loop body; we're done.

See: Off by one error


Dave

  • Comment on Re: Not understanding while loop counting

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://11120546]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others cooling their heels in the Monastery: (1)
As of 2021-09-17 00:52 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?