HP C A.06.05 Reference Manual
Expressions and Operators
Assignment Operators (=, +=, -=, *=, /=, %=,<<=, >>=, &=, ^=, |=)
Chapter 5 87
Assignment Operators (=, +=, -=, *=, /=, %=,<<=, >>=, &=, ^=, |=)
Syntax
lvalue
=
expression
Simple assignment.
lvalue
+=
expression
Addition and assignment.
lvalue
-=
expression
Subtraction and assignment.
lvalue
*=
expression
Multiplication and assignment.
lvalue
/=
expression
Division and assignment.
lvalue
%=
expression
Modulo division and assignment.
lvalue
<<=
expression
Left shift and assignment.
lvalue
>>=
expression
Right shift and assignment.
lvalue
&=
expression
Bitwise AND and assignment.
lvalue
^=
expression
Bitwise XOR and assignment.
lvalue
|=
expression
Bitwise OR and assignment.
Arguments
lvalue
Any expression that refers to a region of storage that can be manipulated.
expression
Any legal expression.
Description
The assignment operators assign new values to variables. The equal sign (=) is the
fundamental assignment operator in C. The other assignment operators provide shorthand
ways to represent common variable assignments.
The Assignment Operator (=)
When the compiler encounters an equal sign, it processes the statement on the right side of
the sign and assigns the result to the variable on the left side. For example: