A while loop is used within programming whenever we need to repeat something an unknown number of times. The loop will continue to repeat whilst the sentinal condition is true. You must therefore be very careful to ensure that your loop will actually terminate!! You should use a while loop whenever you do not know how many times you need to loop, ie; while not at the end of the file; while the program is running; while the user is inputting value.....
The general form for a while loop is as follows :