When programming, it is sometimes useful to repeat a block of code. There are several constructs which help us to tell the computer to run code repeatedly; the For Next construct is one of the most popular ones, particularly when you know how may times you need to repeat the code.
Here is an outline of the For Next construct. The code will loop (repeat) starting at the first number (m), and ending at the last number (n).
In the example below, the loop executes 5 times. Count starts at 1; Count is incremented by 1 each time, until it reaches 5. Each time Count is incremented, the code inside the loop is executed:
For Count = 1 to 5
Answer = Count * 3
Next Count
Using a trace table (see below), we can track the values of Count and Answer, each time the loop is executed: