Chapter 3: Operators

C/C++ has a rich set of operators that can be divided into the following classes: arithmetic, relational and logical, bitwise, pointer, assignment, I/O, and miscellaneous.

Arithmetic Operators

C/C++ has the following seven arithmetic operators:

Operator

Action

Subtraction, unary minus

+

Addition

*

Multiplication

/

Division

%

Modulus

– –

Decrement

+ +

Increment

The +, –, *, and / operators work in the expected fashion. The % operator returns the remainder of an integer division. The increment and decrement operators increase or decrease the operand by one.

These operators have the following order of precedence:

Precedence

Operators

Highest

++  – –  – (unary minus)

 

*  /  %

Lowest

+  –

Operators on the same precedence level are evaluated left to right.




C(s)C++ Programmer's Reference
C Programming on the IBM PC (C Programmers Reference Guide Series)
ISBN: 0673462897
EAN: 2147483647
Year: 2002
Pages: 539

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net