|
9. Precedence and Order of Evaluation |
|
Operators on the same line have the same precedence; rows are in order of decreasing precedence. |
– ++, –, (cast), sizeof have the highest priority
– *, /, % have higher priority than +, -
– ==, != have higher priority than &&, ||
– assignment operators have very low priority |
Use () generously to avoid ambiguities or side effects associated with precedence of operators. |
– y=x*3+2 /* same as y=(x*3)+2 */
– x!=0 && y==0 /* same as (x!=0) && (y==0) */
– d= c>=’0’&& c<=’9’ /* same as d=(c>=’0’) && (c<=’9’) */ |
|
Table. Precedence and Associativity of Operators |
|
|
|
|