# 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

{

&#x20;    \<block of statements>

}

Block:

<figure><img src="/files/O0sSmOvMpnzzCFQO3PaT" alt=""><figcaption></figcaption></figure>

in which the block of statements is executed n times.

The exam reference sheet provides

Text:

REPEAT UNTIL (condition)

{

&#x20;    \<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.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://www.csprinciples.com/big-idea-3/3.8-iteration.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
