> ## Documentation Index
> Fetch the complete documentation index at: https://docs.syntblaze.com/llms.txt
> Use this file to discover all available pages before exploring further.

# C Addition

The `+` operator in C is a polymorphic arithmetic operator that functions either as a unary operator for integer promotion or as a binary operator for arithmetic addition and pointer offset calculation. Its behavior, precedence, and type constraints depend strictly on its arity and the data types of its operands.

## Unary Plus

When used with a single operand, `+` acts as the unary plus operator.

```c theme={"dark"}
+ expression
```

* **Operands:** Must have an arithmetic type (integer or floating-point).
* **Mechanics:** The operator performs *integer promotions* on its operand. If the operand is of a type smaller than `int` (e.g., `char` or `short`), it is promoted to `int` (or `unsigned int`). The value and sign of the operand remain completely unchanged.
* **Associativity:** Right-to-left.
* **Precedence:** High (Level 2), sharing precedence with other unary operators like `-`, `!`, and `~`.

## Binary Plus (Arithmetic Addition)

When used with two arithmetic operands, `+` acts as the binary addition operator.

```c theme={"dark"}
expression1 + expression2
```

* **Operands:** Both operands must have arithmetic types.
* **Mechanics:** The compiler applies the *usual arithmetic conversions* to establish a common real type before performing the addition. For example, if one operand is an `int` and the other is a `double`, the `int` is implicitly converted to a `double` before the sum is calculated.
* **Associativity:** Left-to-right.
* **Precedence:** Medium (Level 4), evaluated after multiplicative operators (`*`, `/`, `%`) and before shift operators (`<<`, `>>`).
* **Overflow Behavior:**
  * **Unsigned Integers:** Addition wraps around using modulo arithmetic ($2^n$, where $n$ is the number of bits in the type). This is well-defined.
  * **Signed Integers:** Overflow results in *Undefined Behavior (UB)*. The compiler assumes signed overflow never occurs and may optimize accordingly.

## Binary Plus (Pointer Arithmetic)

When one operand is a pointer and the other is an integer, `+` performs pointer arithmetic.

```c theme={"dark"}
pointer_expression + integer_expression
integer_expression + pointer_expression
```

* **Operands:** One operand must be a pointer to a completely defined object type. The other must be of an integer type. It is invalid to add two pointers together.
* **Mechanics:** The integer operand is implicitly multiplied by the size of the type the pointer points to (`sizeof(*pointer)`). This calculated byte offset is then added to the pointer's memory address.
* **Type Constraints:** Pointer arithmetic is strictly prohibited on `void*` and function pointers, as their target types have no defined size.
* **Bounds and Undefined Behavior:** The resulting pointer must point to an element within the same array object, or exactly one element past the end of the array. If the calculated address falls outside these bounds, the result is Undefined Behavior.

<div
  style={{ 
display: "flex", 
justifyContent: "space-between", 
alignItems: "center", 
maxWidth: "754px", 
padding: "1rem 0",
marginBottom: "24px"
}}
>
  <span style={{ fontWeight: "bold", fontSize: "1.25rem", color: "var(--tw-prose-headings)", fontFamily: "Inter, ui-sans-serif, system-ui, sans-serif" }}>Tired of Poor C Skills? Fix That With Deep Grasping!</span>

  <a
    href="https://syntblaze.com"
    target="_blank"
    style={{ 
  marginLeft: "24px",
  textDecoration: "none", 
  backgroundColor: "#007AFF",
  color: "#ffffff", 
  padding: "6px 16px", 
  borderRadius: "16px",
  fontSize: "0.9rem",
  fontWeight: "600",
  textAlign: "center",
  transition: "background-color 0.2s ease"
}}
  >
    Learn More
  </a>
</div>

<div style={{ display: "flex", gap: "12px", flexWrap: "wrap" }}>
  <img src="https://mintcdn.com/syntblazellc/-L0ums_2lctDSZ1l/images/skill-tracking.png?fit=max&auto=format&n=-L0ums_2lctDSZ1l&q=85&s=b9b0305c93bb501c9e767b5c76c88835" style={{ width: "30%", minWidth: 60 }} width="621" height="1344" data-path="images/skill-tracking.png" />

  <img src="https://mintcdn.com/syntblazellc/23tyuOzaWS88qFlc/images/nuggets.png?fit=max&auto=format&n=23tyuOzaWS88qFlc&q=85&s=c86c80197299762989e9b882419b2109" style={{ width: "30%", minWidth: 60 }} width="621" height="1344" data-path="images/nuggets.png" />

  <img src="https://mintcdn.com/syntblazellc/-L0ums_2lctDSZ1l/images/bite-sized-exercises.png?fit=max&auto=format&n=-L0ums_2lctDSZ1l&q=85&s=a65f9a38c37ff28ab73ed783c53c60e3" style={{ width: "30%", minWidth: 60 }} width="621" height="1344" data-path="images/bite-sized-exercises.png" />
</div>

<div style={{ display: "flex", gap: "12px", flexWrap: "wrap", marginTop: "12px" }}>
  <img src="https://mintcdn.com/syntblazellc/-L0ums_2lctDSZ1l/images/mastery-chain.png?fit=max&auto=format&n=-L0ums_2lctDSZ1l&q=85&s=748a1763454713e679260fbb95f154a2" style={{ width: "30%", minWidth: 60 }} width="621" height="1344" data-path="images/mastery-chain.png" />

  <img src="https://mintcdn.com/syntblazellc/-L0ums_2lctDSZ1l/images/element-previews.png?fit=max&auto=format&n=-L0ums_2lctDSZ1l&q=85&s=242f61448ff5dd6deaaab2dccc13b507" style={{ width: "30%", minWidth: 60 }} width="621" height="1344" data-path="images/element-previews.png" />

  <img src="https://mintcdn.com/syntblazellc/-L0ums_2lctDSZ1l/images/element-explanations.png?fit=max&auto=format&n=-L0ums_2lctDSZ1l&q=85&s=cf0fc1c31f9cd0fc26716781be05fbc9" style={{ width: "30%", minWidth: 60 }} width="621" height="1344" data-path="images/element-explanations.png" />
</div>
