> For the complete documentation index, see [llms.txt](https://www.csprinciples.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://www.csprinciples.com/big-idea-3/3.8-iteration.md).

# 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="https://1944349550-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-M4BNKwhk8txJ3Zd_j4L%2Fuploads%2FgaZelrEFzLvZxMgTBQDC%2FCapture9.PNG?alt=media&amp;token=e9a4db0c-47d4-4b3e-a709-325d09c45d7f" 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
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

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

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

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

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

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.
