The while statement is used in a while loop in cases when there is a need to repeat the code over and over again till main condition is met. The code inside the while loop gets executed after the condition in the beginning is satisfied; it does not run the codes if the condition is FALSE.

Syntax for WHILE statement

    while (condition)
            // execute code here

Example with a WHILE statement


›› go to examples ››