The FOR-TO-DO Loop Page

The purpose of this program fragment is to show how a loop-control variable can be used to calculate a sequence of numbers using the FOR-TO-DO loop. This fragment prints the first three Natural numbers and their squares.

The Source

The Variables

1   2   3   4   5   6   7   8   9   10   11   NEXT  

The Output

The Source

N.B. This is the only time that the first line of the loop will be highlighted. The loop-control variable i will be initialized to 1. The Turbo Pascal debugger handles the increment later.



Back to Main Page
© 2001 DFStermole
Last Modified 31 Oct 2001