Skip to main content

Questions tagged [while-loop]

Use for questions about a segment of code that repeatedly, at the start of each loop, checks some condition and exits if it is false.

Filter by
Sorted by
Tagged with
18 votes
7 answers

How can the language or tooling notify the user of infinite loops?

I'm trying to teach a friend to code in Python. I've noticed that whenever they write a while loop with an integer increment, such as the one shown below: ...
Redz's user avatar
  • 1,076
9 votes
1 answer

Parsing `do`-`while`, `while`-`do`-`end` and `do`-`end`

Consider the Lua programming language, which has the following constructs involving the keywords do and end: ...
Luatic's user avatar
  • 330
3 votes
5 answers

What are the advantages of providing an until loop construct?

An until loop construct until (x) can almost always be achieved with a while loop while (!x). What's a possible reasoning behind ...
Nimesh Neema's user avatar
18 votes
7 answers

What are the pros and cons of having do ... while loops?

One somewhat rarely used, but still occasionally handy, feature of many programming languages is do ... while loops: ...
Rydwolf Programs's user avatar