The syntax for FOR-TO and FOR-DOWNTO control statements are as follows:
FOR <Control Variable> := <Start Number> TO <End Number> DO <Statement> FOR <Control Variable> := <Start Number> DOWNTO <End Number> DO <Statement>
A FOR control structure is used when we wish to execute a block of code a specific number of times.
The Control Variable is an integer variable. Start Number is the beginning count for the FOR loop and End Number is the final count for the loop. If we wrote the FOR LoopCount := 5 TO 7 DO [block of code] statement, then [block of code] would be executed three times.
FOR-TO increments the Control Variable. FOR-DOWNTO decrements the Control Variable.
We must be careful not to manipulate the Control Variable in the middle of our loop. Doing so will likely yield unpredictable results.