Pages

Saturday, February 13, 2010

OPERATOR PRECEDENCE

Introduction
Since C has various types of operators, it also sets precedence rules so that the value of expressions that involve multiple operators should be deterministic.

Program
[] ( ) ->
Left to right
Array subscript, function call
− + sizeof( ) ! ++ −−

& * ~ (cast)
Right to left
Unary

* / %
Left to right
Binary Multiplicative

+ -
Left to right
Binary Additive

>> <<
Left to right
Shift operators

< <= > >=
Left to right
Relational operators

== !=
Left to right
Equality operators

&
Left to right
Bitwise And operator

^
Left to right
Bitwise Xor operator

|
Left to right
Bitwise Or operator

&&
Left to right
Logical And operator

||
Left to right
Logical Or operator

?:
Left to right
Conditional operator

= += -= *= /= %=

&= -= |= <<= >>=
Right to left
Assignment

,
Right to left
Comma

No comments:

Post a Comment