Loops
Contents
Loops#
Looping a number of times#
FOR Index ← 1 TO 10 OUTPUT Index NEXT Index
Assigning a group of array elements#
DECLARE StudentNames : ARRAY[1:3] OF STRING FOR Index ← 1 TO 10 StudentNames[1] ← "" NEXT Index OUTPUT "First StudentName: ", StudentNames[1]
Looping with a condition#
DECLARE Index : INTEGER DECLARE StudentNames : ARRAY[1:3] OF STRING StudentNames[1] ← "Jim" StudentNames[2] ← "Tony" StudentNames[3] ← "Bob" Index ← 1 WHILE Index <= 3 DO OUTPUT StudentNames[Index] // Change the condition!! Index ← Index + 1 ENDWHILE