The operator priority order table determines the execution order of expressions in C language: highest priority: brackets () unary operators (, --,!), sizeof, &, * (get address) Function call (), array subscript [], pointer member ->, - unary, - multiplication *, division /, modulo % addition, subtraction - left shift<<, right shift>>< , <=, >, >===, !=&, ^Lowest precedence: assignment operator (=)
# Table of precedence order of operators in C language
The precedence order of operators in C language determines the order in which operators in an expression are executed. Operators with higher precedence are executed before operators with lower precedence.Priority order table
Operator | |||
---|---|---|---|
Brackets () | |||
Unary operators (e.g., --, !) | |||
sizeof, &, * (get address) | |||
##(), [], - > | |||
#一元和- | |||
Multiplication*, division/, modulo % | |||
##Addition, subtraction- | |||
Shift left<<, shift right>> | |||
<, <=, > ;, >= | |||
==, != | |||
&, ^ | |||
lowest | Assignment operator (=) | ||
How to use the sequence table |
If two operators have the same precedence, they are executed from left to right.
Brackets can be used to change the execution order of operators, with the highest priority.<code class="c">a + b * c;</code>
<code class="c">(a + b) * c;</code>
Using parentheses changes the execution order of operators. The expression will first perform the addition operation within the brackets, and then perform the multiplication operation.
The above is the detailed content of Priority order table of operators in c language. For more information, please follow other related articles on the PHP Chinese website!