The purpose of this program fragment is to show how a loop-control variable can be used to generate non-sequential values using the WHILE-DO loop. This fragment prints the first three even Natural numbers.
The Source | The Variables |
The Output | |
The Source This statement will initialize the loop-control variable, providing the first value of the desired sequence. | |
The Variables Currently, num contains the default value of 0. | |