While loop
The while loop consists of two parts: the condition and a block of code. The condition is evaluated and if it is true, the block of code is executed. This repeats until the condition evaluates to false. As a pre-test loop, the while loop checks the condition before the block is executed. In contrast, the do-while loop checks the condition after the loop has executed. A while loop would typically be used when you don't know the number of times you would like to loop over the block of code. Instead, code would continue looping until a particular condition is met. When the number of times a loop is to be executed is already known before the execution of the loop, a for loop would be a better choice.