C has a special shorthand that simplifies coding of certain type of assignment statements. For example:
a=a+2;
can be written as:
a += 2
The operator +=tells the compiler that a is assigned the value of a + 2; This shorthand works for all binary operators in C. The general form is:
variable operator = variable / constant / expression
These operators are listed below:
| Operator | Example | Meaning |
|---|---|---|
| += | a += 2 | a = a + 2 |
| -= | a -= 2 | a = a - 2 |
| *= | a *= 2 | a = a * 2 |
| /= | a /= 2 | a = a / 2 |
| %= | a %= 2 | a = a % 2 |
| &&= | a &&= c | a = a && c |
| ||= | a ||= c | a = a || c |


