Assignment operators - cppreference.com

##### cppreference.com

##### Search

Create account

##### Namespaces

- Page
- Discussion

##### Variants

##### Views

- View
- Edit
- History

##### Actions

# Assignment operators

From cppreference.com
< c‎ | language

Assignment operators are binary operators that modify the variable to their left using the value to their right.

Operator | Operator name | Example | Description | Equivalent of
--- | --- | --- | --- | ---
= | basic assignment | a = b | a becomes equal to b | N/A
+= | addition assignment | a += b | a becomes equal to the addition of a and b | a = a + b
-= | subtraction assignment | a -= b | a becomes equal to the subtraction of b from a | a = a - b
*= | multiplication assignment | a *= b | a becomes equal to the product of a and b | a = a * b
/= | division assignment | a /= b | a becomes equal to the division of a by b | a = a / b
%= | modulo assignment | a %= b | a becomes equal to the remainder of a divided by b | a = a % b
&= | bitwise AND assignment | a &= b | a becomes equal to the bitwise AND of a and b | a = a & b
|= | bitwise OR assignment | a |= b | a becomes equal to the bitwise OR of a and b | a = a | b
^= | bitwise XOR assignment | a ^= b | a becomes equal to the bitwise XOR of a and b | a = a ^ b
<<= | bitwise left shift assignment | a <<= b | a becomes equal to a left shifted by b | a = a << b
>>= | bitwise right shift assignment | a >>= b | a becomes equal to a right shifted by b | a = a >> b

### [edit] See Also

Operator precedence

Common operators
assignment | increment decrement | arithmetic | logical | comparison | member access | other
a = b a += b a -= b a *= b a /= b a %= b a &= b a |= b a ^= b a <<= b a >>= b | ++a --a a++ a-- | +a -a a + b a - b a * b a / b a % b ~a a & b a | b a ^ b a << b a >> b | !a a && b a || b | a == b a != b a < b a > b a <= b a >= b | a[b] *a &a a->b a.b | a(...) a, b (type) a ? : sizeof _Alignof (since C11)

Retrieved from "http://en.cppreference.com/mwiki/index.php?title=c/language/operator_assignment&oldid=41444"