Precedence and Associativity of Operators in C | Expressions in C

Preview

Precedence and Associativity of Operators in C

Precedence refers oi the priority given to different operators in C language.

Associativity refers to sequence of evaluation of operators in an expression if operators of same priority appear .



 

Precdence OPERATOR ASSOCIATIVITY
1 (), [] Left to Right
2 !, ~, ++, –, Unary +, Unary -, *, &, (type), sizeof() ) Right to Left
3 *, /, % Left to Right
4 + , – Left to Right
5 << , >> Left to Right
6 <, <= , > , >= Left to Right
7 = =, != Left to Right
8 & Left to Right
9 ^ Left to Right
10 | Left to Right
11 && Left to Right
12  || Left to Right
13 ?: Right to Left
14 =, +=, -=, /=, *=, ^=, !=, ,=, >>= Left to Right
15 COMMA OPERATOR(,) Left to Right



Best Books of Computer Science





Lesson tags: Associativity of operators in c, precedence of operators in C
Back to: C Programming Language