A while loop is a control structure used in many programming languages to continuously execute a set of instructions as long as a particular condition is met.
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. The while loop can be thought of as a repeating if statement.
The while construct consists of a block of code and a condition. The condition is evaluated, and if the condition is true, the code within the block is executed. This repeats until the condition becomes false. Because the while loop checks the condition before the block is executed, the control structure is often also known as a pre-test loop. Compare this with the do-while loop, which tests the condition after the loop has executed.
The syntax for the while loop for many computer languages is as follows:
while (true) {
//do complicated stuff
if (someCondition)
break;
//more stuff
}
(excerpted from http://en.wikipedia.org/wiki/While_loop, with minor changes)
There are several types of different while loops in modern computing. One of these loops is called a sentinel loop. This loop will run until a "sentinel" value is hit. An example follows in pseudo code (this example is a simple accumulator):
Initialize a data type to not the sentinel value
while(data!=(sentinel value)){
do something
ask for more data (which will be put into the data variable)
}