In most computer programming languages, a while loop is a control flow statement that allows code to be executed repeatedly based on a given Boolean condition.
For example, in the languages C, Java, C#,[2] Objective-C, and C++, (which use the same syntax in this case), the code fragment first checks whether x is less than 5, which it is, so then the {loop body} is entered, where the printf function is run and x is incremented by 1.
It is possible, and in some cases desirable, for the condition to always evaluate to true, creating an infinite loop.
While repeats one statement (unless enclosed in a begin-end block) as long as the condition is true.
While loops are frequently used for reading data line by line (as defined by the $/ line separator) from open filehandles: Non-terminating while loop: In Racket, as in other Scheme implementations, a named-let is a popular way to implement loops: Using a macro system, implementing a while loop is a trivial exercise (commonly used to introduce macros): However, an imperative programming style is often discouraged in Scheme and Racket.