Programming Course for Beginners - ZedLX

The Easiest Online Computer Programming Course, for Free

Iteration [1/10]


Iteration

A for loop executes statements of a statement block multiple times.

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

A statement block consists of statements enclosed inside braces {}. Sometimes, they are also called “curly brackets”.

It can be said that a for loop repeats, or iterates, the execution of a following statement block.

In this example, the number of iterations is 7.

The statement sleepMs(600) slows down execution of the program.

Exercises:

1. In the source code of this program, the number 600 is the argument of sleepMs function. Change the number 600 to number 150.
[Run the program]

2. Change the argument of the sleepMs function to value 900.
[Run the program]

Loading...