When we do operators calculations we need know the below table.
|
Token |
Operator |
Precedence |
Associativity |
|
() |
function call |
1 |
left-to-right |
|
[] |
array element |
1 |
left-to-right |
|
a++ |
postfix increament |
1 |
left-to-right |
|
a- - |
postfix decreament |
1 |
left-to-right |
|
++a |
prefix increament |
2 |
right-to-left |
|
- -a |
prefix decreament |
2 |
right-to-left |
|
+ |
unary plus |
2 |
right-to-left |
|
- |
unary minus |
2 |
right-to-left |
|
! |
Logical negation |
2 |
right-to-left |
|
~ |
one's complement |
2 |
right-to-left |
|
* |
indirection |
2 |
right-to-left |
|
& |
address |
2 |
right-to-left |
|
sizeof |
size(in bytes) |
2 |
right-to-left |
|
(type) |
type cast |
2 |
right-to-left |
|
* |
multiplication |
3 |
left-to-right |
|
/ |
division |
3 |
left-to-right |
|
% |
modulus |
3 |
left-to-right |
|
+ |
addition |
4 |
left-to-right |
|
- |
subtraction |
4 |
left-to-right |
|
<< |
left shift |
5 |
left-to-right |
|
>> |
right shift |
5 |
left-to-right |
|
< |
less than |
6 |
left-to-right |
|
<= |
less than or equal to |
6 |
left-to-right |
|
> |
greater than |
6 |
left-to-right |
|
>= |
greater than or equal to |
6 |
left-to-right |
|
== |
equality |
7 |
left-to-right |
|
!= |
inequality |
7 |
left-to-right |
|
& |
bitwise AND |
8 |
left-to-right |
|
^ |
bitwise XOR |
9 |
left-to-right |
|
| |
bitwise OR |
10 |
left-to-right |
|
&& |
Logical AND |
11 |
left-to-right |
|
|| |
Logical OR |
12 |
left-to-right |
|
?: |
conditional expression |
13 |
right-to-left |
|
= *= /= %= += -= &= ^= |= <<= >>= |
assignment operators |
14 |
right-to-left |
|
, |
comma operator |
15 |
left-to-right |
0 Comments
Post a Comment