Programming Course for Beginners - ZedLX

The Easiest Online Computer Programming Course, for Free

Iteration [1/10]


Iteration with Loops

A for loop executes a block of statements multiple times.

Press the F8 key to run the program, or click the Run button.

A statement block is a group of statements enclosed inside braces {}. Braces are sometimes called “curly brackets”.

A for loop repeats, or iterates, the execution of the statement block.

In this example, the for loop will iterate 7 times.

Additionally, the statement sleepMs(600) is used to slow down execution of the program.

Exercises:

1. In the source code, the number 600 is the argument of the sleepMs function. Change the number 600 to number 150 to see how it affects the program speed.
[Run the program]

2. Now, change the argument of the sleepMs function to 900.
[Run the program]

Loading...