> 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.6-conditionals.md).

# 3.6 Conditionals

## 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 selection without using a programming language.

## Essential Knowledge

Selection determines which parts of an algorithm are executed based on a condition being true or false.

## Learning Objective

For selection:

a. Write conditional statements.

b. Determine the results of conditional statements.

## Essential Knowledge

Conditional statements, or “if-statements,” affect the sequential flow of control by executing different statements based on the value of a Boolean expression.

The exam reference sheet provides:

Text:

IF (condition)

{

&#x20;    \<block of statements>

}

<figure><img src="https://1944349550-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-M4BNKwhk8txJ3Zd_j4L%2Fuploads%2Fvv9bcX0IVVdmyF54UsYH%2FCapture8.PNG?alt=media&amp;token=fba25e29-0517-497d-a930-11a06f05323d" alt=""><figcaption></figcaption></figure>

in which the code in block of statements is executed if the Boolean expression condition evaluates to true; no action is taken if condition evaluates to false.

The exam reference sheet provides:

Text:

IF (condition)

{

&#x20;    \<block of statements>

}

ELSE&#x20;

{

&#x20;    \<second block of statements>

}

in which the code in first block of statements is executed if the Boolean expression condition evaluates to true; otherwise, the code in second block of statements is executed.


---

# 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.6-conditionals.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.
