While loop statement is used when programmer doesn't knows how many times the code will be executing before starting the loop, as it depends upon the users input.
Syntax
while (test expression is true)
{
statement;
statement;
}
Executes the loop till the test expression condition is true.
You can create a while loop that will never end by using number 1. Since 1 is always true, the loop will continue unless break statement is reached in the loop body. |