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 |
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. | |