---
title: 3.7 Compound Assignment Operators
description: "Compound assignment operators combine an arithmetic or bitwise operation with assignment. They modify the value of the left operand using the value on the right. ``` #include int main() { int number = 10; number += 5; printf(\"After += :…"
url: "https://edcret.in/docs/c-programming/operators-and-expressions/3-7-compound-assignment-operators-2/"
updated: "2026-09-07"
category: C Programming / Operators and Expressions
---

# 3.7 Compound Assignment Operators

Compound assignment operators combine an arithmetic or bitwise operation with assignment. They modify the value of the left operand using the value on the right.

```
#include <stdio.h>

int main()
{
    int number = 10;

    number += 5;
    printf("After += : %d\n", number);

    number -= 3;
    printf("After -= : %d\n", number);

    number *= 2;
    printf("After *= : %d\n", number);

    number /= 4;
    printf("After /= : %d\n", number);

    number %= 3;
    printf("After %%= : %d\n", number);

    return 0;
}
```

### Example Output

```
After += : 15
After -= : 12
After *= : 24
After /= : 6
After %= : 0
```

### Explanation

For example:

```
number += 5;
```

is equivalent to:

```
number = number + 5;
```

The common compound assignment operators are:

| Operator | Equivalent operation |
| --- | --- |
| `+=` | `a = a + b` |
| `-=` | `a = a - b` |
| `*=` | `a = a * b` |
| `/=` | `a = a / b` |
| `%=` | `a = a % b` |
| `&=` | `a = a & b` |
| \` | =\` |
| `^=` | `a = a ^ b` |
| `<<=` | `a = a << b` |
| `>>=` | `a = a >> b` |

The operator performs the specified operation and stores the resulting value back in the left operand.
