EZ Programing Demos

Slow motion, step by step, animated demonstrations of basic computer programing techniques

Links to topics:

Current topic:

Repeat

A repeat loop cycles through a list of commands again and again till done.

What is the repeat loop?

The repeat loop contains an expression that controls how many times the loop cycles. This is simply a number in our example here. A repeat loop also contains a body. The body is the list of computer commands that will be repeated.

Where is the repeat loop body?

In our simple example the body has but one command, a print command. The body could contain a much longer list of commands to be repeated.

How does the repeat loop work?

Once started, the body of the repeat loop cycles as many times as the value of the expression after the repeat command.

 Slow  Medium  Fast 
Click 'Run' to go.

Our repeat loop runs for a predetermined number of cycles. Once started, it will go through all of its cycles. There is nothing you can do in the loop's body to make it quit early or run a few more cycles. One of the loop structures found in the computer language LOGO works a lot like this.

There are many other types of loops in computer languages. Some types rely on the repeated evaluation of a Boolean expression to decide if they should run one more cycle or not. Those types might run a few cycles, or many, or maybe none.

 

Here's the flowchart for this repeat loop demo:

 

Imaginary computer code for this demo:

    
    repeat(5)
    {
      printLine("Hello.");
    }
    

 

Suggested next article:

At EZ Math Movie

EZ Math Movie is a site that can help you experiment with and understand many topics in mathematics. Its main feature is an interactive animated (x, y) graph that you control with an actual programing language. There are many examples and tutorials, and EZ Math Movie is crossed referenced with both EZ Programing Demos and Zona Land Education.

 

Zona Land Education is a site with explanations and interactive diagrams covering many topics in physics and mathematics. Zona Land Education is cross referenced with EZ Math Movie, and it contains several animations that use EZ Math Movie's programing language.