About operators in C++ language

Operators in C++ are symbol that can modify one or more than one operands. They are used to perform several mathematical calculations. If we write 10 + 20 = 30, then ‘+‘ is called the operator here. It has works on two operands 10 and 20.

In C++, we use various operators to perform different mathematical calculations. For this purpose, there are several types of operators in C++. Here is the types of operators in C++.

Types of operators in C++

Type Operators list
Arithmetic operators
+, -, *, /, %, ++, --
Logical operators
&&, ||, !
Relational operators
<, >, >=, <=, ==, !=
Assignment operators
=, +=, -=, *=, /=, %=, >>=, <<=, &=, ^=, |=
Bitwise operators
&, |, ^, ~
Other operators
sizeof, ?:, ,

Operators precedence and associativity

Operators Description Precedence Associativity
( )
Function expression
01
Left to Right
[ ]
Array
02
Left to Right
->
Structure operator
03
Left to Right
-
Unary minus
04
Right to Left
++ --
Increment Decrement
05
Right to Left
~
One's complement
06
Right to Left
& *
Pointer
07
Right to Left
(data type)
Type cast
08
Right to Left
sizeof
sizeof operator
09
Right to Left
>> <<
Right and Left shift
10
Left to Right
* / %
Multiplication, division and reminder operator
11
Left to Right
+ -
Addition Subtraction
12
Left to Right
<
Less than
13
Left to Right
>
Greater than
14
Left to Right
<=
Less than or equal
15
Left to Right
>=
Greater than or equal
16
Left to Right
==
Equal to operator
17
Left to Right
!=
Not equal to operator
18
Left to Right
&&
Logical AND operator
19
Left to Right
||
Logical OR operator
20
Left to Right
!
Logical NOT operator
21
Right to Left
&
Bitwise AND operator
22
Left to Right
^
Bitwise EX-OR operator
23
Left to Right
|
Bitwise OR operator
24
Left to Right
=
Assignment operator
25
Right to Left
*=
Assignment operator
26
Right to Left
/=
Assignment operator
27
Right to Left
%=
Assignment operator
28
Right to Left
+=
Assignment operator
29
Right to Left
-=
Assignment operator
30
Right to Left
&=
Assignment operator
31
Right to Left
^=
Assignment operator
32
Right to Left
|=
Assignment operator
33
Right to Left
<<=
Assignment operator
34
Right to Left
>>=
Assignment operator
35
Right to Left
,
Comma operator
36
Right to Left
?:
Conditional operator
37
Right to Left

Previous pageStorage classes in C++

Next pageMath functions in C++