> For the complete documentation index, see [llms.txt](https://university-west.gitbook.io/programming-paradigms/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://university-west.gitbook.io/programming-paradigms/programming-fundamentals/control-structures/selection-conditional.md).

# Selection (Conditional)

#### Selection Control Structure in Computer Programming

The selection control structure, also commonly referred to as the conditional control structure, is a fundamental concept in computer programming that enables a program to choose different paths of execution based on certain conditions. This structure is critical for making decisions in the code, allowing programs to behave dynamically and respond differently to various inputs or situations.

**Definition**

At its core, a selection control structure evaluates a condition (usually a comparison between two values or variables) and then directs the program flow to one or more paths based on the outcome of that evaluation. If the condition evaluates to true, one path of execution is followed; if false, another path is taken.

**Main Types**

1. **If Statement:** The most basic form of selection, allowing for the execution of a block of code if a specified condition is true.
2. **If-Else Statement:** Extends the `if` statement to provide an alternative path of execution if the condition is false.
3. **Switch Statement:** Allows a variable to be tested for equality against a list of values, each with its own block of execution.

**Importance**

Using selection control structures makes it possible to create more flexible and powerful software applications. They are essential for tasks such as validating user input, making calculations based on dynamic data, and navigating through complex workflow processes. Without these structures, programs would be linear and much less capable of handling real-world complexities.

In summary, selection control structures are a cornerstone of computer programming, providing the necessary logic to make decisions and execute different code based on various conditions.


---

# 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 dynamically by asking a question.

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

```
GET https://university-west.gitbook.io/programming-paradigms/programming-fundamentals/control-structures/selection-conditional.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

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.
