---
title: 3.6 Simple Assignment Operator (=)
description: "The assignment operator (`=`) assigns the value of the right operand to the left operand. The left operand must be a modifiable object, such as a variable, while the right operand can be a value, variable, or expression. The assignment…"
url: "https://magenta-tarsier-454184.hostingersite.com/docs/cpp-programming/operators-cplusplus/3-6-simple-assignment-operator/"
updated: "2026-07-28"
category: C++ Programming / Operators
---

# 3.6 Simple Assignment Operator (=)

The assignment operator (`=`) assigns the value of the right operand to the left operand. The left operand must be a modifiable object, such as a variable, while the right operand can be a value, variable, or expression.

The assignment operator copies the computed value of the right-hand side into the left-hand side variable. Any previous value stored in the variable is replaced.

## Source Code

```
#include <iostream>

int main()
{
    int number;

    number = 100;

    std::cout << "Number: " << number << '\n';

    return 0;
}
```

## Output

```
Number: 100
```

## Explanation

- The assignment operator (`=`) stores the value of the right operand in the left operand.
- `number = 100;` assigns the integer value `100` to the variable `number`.
- Any previous value stored in `number` is replaced by the new value.
- The left operand must be a modifiable variable or object.
- The right operand may be a constant, variable, function return value, or expression.
- The assignment operator does not compare values; it performs value assignment.
- `std::cout` displays the value stored in the variable.
- `return 0;` terminates the program successfully.
