The syntax for a FOR-TO and FOR-DOWNTO control statements follow:
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 value 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 statement FOR LoopCount := 5 TO 7 DO [block of code] , 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 ...