> 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/operators.md).

# Operators

#### Operators in Computer Programming

Operators in computer programming are special symbols or keywords that are used to perform operations on operands (values or variables). These operations can range from basic arithmetic calculations to complex logical evaluations. Operators are fundamental to most programming languages, allowing the manipulation of data and the control of program flow.

**Types of Operators:**

1. **Arithmetic Operators:**
   * Used for performing mathematical calculations.
   * Common operators include `+` (addition), `-` (subtraction), `*` (multiplication), `/` (division), and `%` (modulo operation, which gives the remainder of a division).
2. **Relational (Comparison) Operators:**
   * Used for comparing two operands.
   * Include `==` (equal to), `!=` (not equal to), `>` (greater than), `<` (less than), `>=` (greater than or equal to), and `<=` (less than or equal to).
3. **Logical Operators:**
   * Used to perform logical operations, typically on boolean values.
   * Include `&&` (logical AND), `||` (logical OR), and `!` (logical NOT).
4. **Assignment Operators:**
   * Used to assign values to variables.
   * The most basic assignment operator is `=`. There are also compound assignment operators like `+=`, `-=`, `*=` and `/=`, which combine arithmetic and assignment.
5. **Bitwise Operators:**
   * Operate on individual bits of integer operands.
   * Include `&` (bitwise AND), `|` (bitwise OR), `^` (bitwise XOR), `~` (bitwise NOT), `<<` (left shift), and `>>` (right shift).
6. **Unary Operators:**
   * Operate on a single operand.
   * Examples include `++` (increment), `--` (decrement), and `-` (negation).
7. **Ternary Operator (Conditional Operator):**
   * A shorthand for the `if-else` statement.
   * In many languages, it's represented as `? :`. For example, `condition ? expression1 : expression2`.

**Characteristics of Operators:**

* **Precedence:** Operators have a defined precedence which determines the order in which they are evaluated in expressions. For example, multiplication and division have higher precedence than addition and subtraction.
* **Associativity:** Defines the order in which operators of the same precedence are processed. For example, in left-to-right associativity, operators are evaluated from left to right.

**Importance in Programming:**

Operators are crucial in programming as they form the backbone of most computational and logical operations. Understanding how to use them effectively is key to writing efficient and readable code. Different programming languages might have variations in operators and their behaviors, but the fundamental concepts remain largely the same.


---

# 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://university-west.gitbook.io/programming-paradigms/programming-fundamentals/operators.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.
