Programming for Kids - ZedLX

The Easiest Way to Learn Computer Programming, for Free

while Loop and Keyboard [11/11]

This program uses a do-while loop. The condition of a do-while loop is verified only at the end of each iteration. Therefore, a do-while loop is guaranteed to perform at least one iteration.

A do-while loop repeats a sequence of statements. A statement block is not required.

* * *

-- Syntax of do-while loops --

The syntax of a do-while loop is slightly more relaxed in ZedLX compared to other programming languages. In other languages, a do-while loop containing multiple statements requires curly brackets {} to enclose the statement block.

In ZedLX, to simplfy the syntax, curly braces are not required.

* * *

-- do-while is a plain statement --

A do-while loop statement is a plain statement, because it must always end with a semicolon (;) symbol when it is not a part of a statement list. When a do-while statement is a part of a statement list, it can be ended with a colon (:).