While loop are used to allow a block of code or the program to run a certain number of time. While loop are coded once but run a number of times. For while loop we use a conditional statement as long as the conditional statement is true that block of code will execute but if the statement is false it will exit the while loop. To exit, from the while loop we use a pre-increment counter.
Below is the snippet of the code on how the while loop will be executed:
