Learn to Program with ZedLX

Free Online Programming Course for Beginners

Basics of for Loops [5/10]

In this example, the loop control variable is named k.
[Run the program]

The variable k is used in the expression k*3.

A variable name is a primary expression. Primary expressions can be combined to form more complex expressions.

Numbers, like 3, are also primary expressions. In this example, the number 3 is a part of the compound expression k*3.

Exercises:

1. Add this statement at the end of the source code (below the loop body): println "Program ends"; [Run the program]

2. Insert this statement inside the for loop body: sleepMs(200); [Run the program]

Loading...