3.8 Iteration

Enduring Understanding

The way statements are sequenced and combined in a program determines the computed result. Programs incorporate iteration and selection constructs to represent repetition and make decisions to handle varied input values.

Learning Objective

Express an algorithm that uses iteration without using a programming language.

Essential Knowledge

Iteration is a repeating portion of an algorithm. Iteration repeats a specified number of times or until a given condition is met.

Learning Objective

For iteration:

a. Write iteration statements.

b. Determine the result or side effect of iteration statements.

Essential Knowledge

Iteration statements change the sequential flow of control by repeating a set of statements zero or more times, until a stopping condition is met.

The exam reference sheet provides

Text:

REPEAT n TIMES

{

<block of statements>

}

Block:

in which the block of statements is executed n times.

The exam reference sheet provides

Text:

REPEAT UNTIL (condition)

{

<block of statements>

}

in which the code in block of statements is repeated until the Boolean expression condition evaluates to true.

In REPEAT UNTIL(condition) iteration, an infinite loop occurs when the ending condition will never evaluate to true.

In REPEAT UNTIL(condition) iteration, if the conditional evaluates to true initially, the loop body is not executed at all, due to the condition being checked before the loop.

Last updated