Home >Backend Development >C#.Net Tutorial >c language operator precedence

c language operator precedence

尚
Original
2020-03-03 14:36:0833278browse

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:

##3Type conversion operator: (type name) From right to left##456##7Relational operator:< <= >>=From left to right8Equality operator: == !=Left to right9Bitwise operator AND: &Left to right10Bitwise operator XOR: ^From left to right11Bitwise operator OR: | Left to rightLogical operator AND: &&Logical operator OR: || Conditional operator: ?:Assignment operator: =   =     -=     *=   /= %=      &=                                                                                                                            <<= >>=
Priority Operator Associative Law
1 Suffix Operator: [] () · -> --(type name){list} from left to right
2 Unary operators: -- ! ~ - - * & sizeof_Alignof 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
##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!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn