Translate

Friday 11 May 2012

Priority of Operators in C++



Operator
Priority number
Associativity
( ),[ ]
1
L->R
-, +(unary), ++, --, !, ~, sizeof(), casting operator, pointer
2
R->L
*, /, %
3
L->R
+, -
4
L->R
<<, >>
5
L->R
&
6
L->R
|
7
L->R
^
8
L->R
>, >=, <, <=
9
L->R
==, !=
10
L->R
&&
11
L->R
||
12
L->R
?, :
13
L->R
Shorthand operators
14
R->L
,
15
L->R


L-> left
R-> right

Note:- There is no difeerence among the operators which have same priority. For instance
                                                         + and -
will be evaluated in the order in which they are used in expression.

1 comment:

Total Pageviews