While Loops

While loops are designed to do something until a certain condition evaluates to false. This means, that a while loop could also run infinitely when the condition never gets fulfilled.
Like the if statement, the condition of the while loop must evaluate to a boolean value, but can hold complex, nested expressions.

Here is an example of a simple while loop:

int counter = 0;
while counter < 20 {
    printf("Loop run %d", counter);

If you would want to achieve an intentional endless loop, you would write something like this:

while true {
    printf("This is gonna run forever ...");

Usage of loop alternatives

If you somehow know how many times you want to execute something, we recommend you to use a for loop instead. Those have better possibilities for extensibility and are more programmer-friendly.