C20. C Arithmetic Operators


Arithmetic Operators
The arithmetic operators  >operators that perform addition, subtraction, multipli­cation, and division  >are the workhorses of many programming languages, includ­ing C.
Unary
Binary




+ unary plus
 - unary minus
Additive
Multiplicative
+ addition -subtraction

* multiplication / division
 % remainder
The additive and multiplicative operators are said to be binary because they require two operands. The unary operators require one operand:
i = +1;  /* + used as a unary operator */ j j= -i;  /* - used as a unary operator */
The unary + operator does nothing; It's used primarily to emphasize that a numeric constant is positive.
The binary operators probably look familiar. The only one that might not is %, the remainder operator. The value of i % j is the remainder when i is divided by j.

No comments: