Of course, counted loops are not just part of turtle programming. They can be used whenever actions need to be repeated a set number of times.
A loop to output the 7 times table.
This next program will display the 7 times table using a counted loop.
This flowchart starts with the process and decision boxes that you need to now view as the ‘For…To…Step’ loop statement. The decision this time is to test to see if we have exceeded 12 – we are going to do the 7 times table up to 12 times.
Straight after the decision box, we set a variable ‘Product’ to equal the value of the loop variable times 7. It is perfectly OK to use the loop variable but it can be unpredictable to alter it; far better to let your program look after its values.
The final flowchart symbol in the loop indicates that we are going to output some information to the screen – in this case the value of the loop variable followed by some literal text and finally the value of the ‘Product’ variable.
Check over on the right (or below) how this looks as Small Basic code.