Programming Statements


Iterative DO Statements

The general form of the iterative DO statement is as follows:

  • DO variable=start TO stop <BY increment>;

The value of the variable matrix is initialized to the value of the start matrix. This value is then incremented by the increment value (or by 1 if increment is not specified) until it is greater than or equal to the stop value. (If increment is negative, then the iterations stop when the value is less than or equal to stop.)

For example, the following statement specifies a DO loop that initializes i to the value 1 and increments i by 2 after each loop. The loop ends when the value of i is greater than 10.

y = 0;
do i = 1 to 10 by 2;
   y = y + i;
end;