What is while loop
While loop is generally used when we don't how many times a loop must run. It allows code to be executed repeatedly based on some given condition.
Syntax of while loop-
while ( condition )
//body of while loop
int x = 0;
while ( x < 5 ) // Condition is the value of x is less than 5
This loop run successfully until the value of x is greater than 4.