Operator Precedence : Associativity and Priority
C Programming Operator Precedence and Associativity
Description | Operator | Associativity |
Increment Decrement Negation Unary Minus Sizeof | ++ - ! - sizeof | R -> L |
Multiplication Division Modulus | * / % | L -> R |
Addition Subtraction | + - | L -> R |
Shift Operator | << >> | L -> R |
Less Than Greater Than Less Than and Equal to Greater Than and Equal to | < > <= >= | L -> R |
Equal to Not Equal To | == != | L -> R |
Logical AND | && | L -> R |
Logical OR | || | L -> R |
Conditional | ?: | R -> L |
Assignment | = += -= *= /= | R -> L |
Comma | , | L -> R |
Notes :
- Comma Operator Has Lowest Precedence .
- Unary Operators are Operators having Highest Precedence.
- Sizeof is Operator not Function .
- Operators sharing Common Block in the Above Table have Equal Priority or Precedence .
- While Solving Expression , Equal Priority Operators are handled on the basis of FIFO [ First in First Out ] i.e Operator Coming First is handled First.
Some Definitions :
Unary Operator : |
|
Binary Operator |
|
Important Terms :
Associativity |
|
Precedence |
|