Home >Backend Development >C#.Net Tutorial >c language operator precedence
An expression can contain multiple operators. In this case, the precedence of the operators determines which part of the expression is processed as the operand of each operator.
Recommended: "c Language Tutorial"
If two operands in an expression have the same priority, then their associativity determines They are combined from left to right or right to left.
The precedence and associativity of all C language operators:
Priority | Operator | Associative Law | |
---|---|---|---|
1 | Suffix Operator: [] () · -> --(type name){list} | from left to right | |
2 | Unary operators: -- ! ~ - - * & sizeof_Alignof | right to left | |
Type conversion operator: (type name) | From right to left | ||
Multiplication and division operators: * / % | From left to right | ||
Addition and subtraction operators: - | From left to right | ||
Shift operator:<< >> | From left to right | ##7 | |
From left to right | 8 | ||
Left to right | 9 | ||
Left to right | 10 | ||
From left to right | 11 | ||
Left to right | ##12 | ||
Left to right | 13 | ||
From left to right | 14 | ||
Right to left | 15 | ||
From right to left | |||
16 | Comma operator:, | From left to right |
#For more programming-related content, please pay attention to the Programming Introduction column on the php Chinese website!
The above is the detailed content of c language operator precedence. For more information, please follow other related articles on the PHP Chinese website!