Computer Languages
Elements - Loops


Loops are useful for repeating parts of a program. An example of a loop is the 'do/while' structure. This will repeatedly execute a section of program until the end condition is satisfied.

In the pseudo code below, 1 is added to the value of 'counter' continuously while the value of 'counter' is less than 2000.

do

counter=counter+1

while(counter<2000)

This could be used for putting a simple time delay in your program. The delay would be increased by increasing 2000. Other looping structures can be used, such as 'for/next' or 'repeat/until', to achieve the same results.