Assignment Operators in C
C language provides one main assignment operator (=) which assigns to a variable on its LHS the outcome of some expression on its RHS. We have been using this operator since program 1. It is a binary operator. In addition, C language provides a set of shorthand assignment operators of the form
variable arithmetic/bitwise-Operator = expression;
These operators are very useful when in an expression a variable on LHS is repeated immediately on RHS. As an example, the statement below
x = x + 22;
can be written as
x += 22;
Table 1 lists all possible shorthand assignment operators along their equivalent expressions.
Table 1: Usage and meaning of Shorthand operators