Do While Loop
by
, January 29th, 2012 at 04:58 PM (1860 Views)
We use the Do While Loop when we want to run a set of instructions before testing to see if a condition is true. The difference between a Do While Loop and a While Loop is that the While Loop tests the condition first and then runs the instructions.
We have a counter initialised to zero. It's going to then output the counter as zero and then increment it by 1. It then checks to see if the while section will permit it to iterate again.
If our counter had been initialised to 50, it would output 50 and then end, because the while section sees that the counter isn't actually <= 10.
The only perameter used in the while part is when you want it to iterate. In this case it's while the counter is less than or equal to 10. Simple enough?