C & C++ Programming

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.

 

RS Technopoint Training Institute © All Right Reserved.