User`s manual

234 digi.com Operators
Pre- or post-increment is a unary operator designed primarily for convenience. If the ++ precedes an oper-
and, the operand is incremented before use. If the ++ operator follows an operand, the operand is incre-
mented after use.
int i, a[12];
i = 0;
q = a[i++]; // q gets a[0], then i becomes 1
r = a[i++]; // r gets a[1], then i becomes 2
s = ++i; // i becomes 3, then s = i
i++; // i becomes 4
If the ++ operator is used with a pointer, the value of the pointer increments by the size of the object (in
bytes) to which it points. With operands other than pointers, the value increments by 1.
Pre- or post-decrement. If the –– precedes an operand, the operand is decremented before use. If the ––
operator follows an operand, the operand is decremented after use.
int j, a[12];
j = 12;
q = a[––j]; // j becomes 11, then q gets a[11]
r = a[––j]; // j becomes 10, then r gets a[10]
s = j––; // s = 10, then j becomes 9
j––; // j becomes 8
If the –– operator is used with a pointer, the value of the pointer decrements by the size of the object (in
bytes) to which it points. With operands other than pointers, the value decrements by 1.
Modulus. This is a binary operator. The result is the remainder of the left-hand operand divided by the
right-hand operand.
const int i = 13;
j = i % 10; // j gets i mod 10 or 3
const int k = -11;
j = k % 7; // j gets k mod 7 or -4
++
––
%