While LoopSyntax :
This loop will continuously execute the statements in the body as long as a given condition is true. This loop must be handled with care. Always make sure that the given condition will be met - or this loop will continue forever. Let us see an example with the while loop that uses while loop in a situation very similar to the one given in the for loop example.
This basically displays all the elements in an array - the same thing we did using the for loop. Notice how the while loop differs from the for loop. In the while loop, only the condition will be given inside the while loops parenthesis - '(' and ')'.blog comments powered by Disqus