C language operator priority order is: bracket members first; all single items second; multiplication and division remainder three, addition and subtraction four; shift five, relationship six; equality (and) inequality ranking Seven; bitwise AND, XOR and bitwise OR, "three-thirds of the world" eighty or ninety; logical OR and AND, twelve and eleven; condition is higher than assignment; comma operation level is the lowest.

There are fifteen priorities in total:
Priority |
Operator |
Name or meaning |
Used form |
Combined direction |
Description |
1 |
[] |
Array subscript |
Array name [constant expression] |
Left to right |
|
() |
Parentheses |
## (expression)/function name (parameter list) | |||
| . | Member Select(object) | Object.Member name |
|||
| ##-> | Member selection (pointer) | Object pointer->Member name | |||
| ##- | Negative operator | -expression | Right to left | Unary operator | |
| Forced type conversion | (data type) expression |
|
|||
| Increment operator | Variable name/variable name | Single Operator | |||
| Decrement operator | --Variable name/Variable name-- |
Unary operator |
|||
* |
Value operator |
*Pointer variable |
Unary operator |
||
& |
Get address operator |
& variable name |
Unary operator |
||
! |
Logical NOT operation Symbol |
!Expression |
Unary operator |
||
~ |
Bitwise negation operator |
~Expression |
Unary operator |
||
sizeof |
length operator |
sizeof(expression) |
|||
| ##3 | / | ##exceptexpression/expression | left to right | Binary operator | |
| Multiply | expression*expression | binary operator | |||
| Remainder (modulo) | Integer expression/integer expression | Binary operation Symbol | |||
| plus | Expression expression | Left to right | Binary Operator |
||
- |
Minus |
Expression-expression |
Binary operator |
||
|
5 |
Shift left |
Variable |
Left to right |
Binary operator |
|
| ##>> | Shift right | Variable>>Expression | Binary operator | ||
| 6 | ##>is greater than |
| Expression>ExpressionLeft to right | Binary Operator |
|
>= |
Greater than or equal to |
expression>=expression |
binary operator |
||
| # # | ##less thanexpression | ||||
| Expression< ;=expression | binary operator | ||||
| == | equal to | expression==expression | left to right | Binary operator | |
is not equal to |
expression!= expression |
binary operator |
|||
8 |
& |
## bitwise and | Expression&expression | Left to right | Binary operator |
| 9 | ^ | Bitwise XOR | Expression^Expression | Left to right | Binary operator |
| 10 | | | bitwise OR | expression|expression | Left to right | Binary operator |
| ##11 | ##&&Logic and | Expression&&expression | Left to right | Binary operator | |
| || | ##Logical or | Expression||Expression | Left to right | Binary operator | ##13 |
?: |
Conditional operator |
Expression 1 ? Expression 2: Expression 3 |
right to left |
ternary operator |
14 |
= |
Assignment operator |
Variable = expression |
right to left |
||
/= |
Assignment after division |
Variable/=Expression |
|||
*= |
Multiply and assign value |
Variable*=expression | |||
%= |
Assign a value after taking the modulus |
Variable% =Expression |
|||
= |
Assignment after addition |
Variable = expression |
|||
-= |
Assignment after subtraction |
Variable-=Expression |
|||
Assign value after left shift |
Variable |
||||
| #>>= | Assign value after right shift | Variable>>=expression | |||
| &= | ##Assignment after bitwise ANDVariable&=Expression | ||||
| Assignment after bitwise XOR | Variable^=expression | ||||
| ##Assignment after bitwise OR |
Variable|=Expression |
|
##15 | ||
, |
Comma operator |
Expression, expression,... |
Left to right |
Operations sequentially from left to right |
##Instructions:
For operators with the same priority, the order of operations is determined by the combination direction.
Function:
- ##Bracket members no. 1; //Bracket operator []() Member operator. ->
- All unary operators Second; //All unary operators such as, --, ( Positive), -(negative), pointer arithmetic*, &
- multiplication and division with remainder three, addition and subtraction four; //This "remainder" refers to the remainder operation, that is, %
- Shift five, relationship six; //Shift operator: >, relationship: > =
- bitwise AND, XOR and bitwise OR; //These are all It is a bitwise operation: Bitwise AND (&) XOR (^) Bitwise OR (|)
-
"三三天下"八九十;
Logical OR and AND ; ; - The condition is higher than the assignment, //The ternary operator's priority is ranked 13th, only higher than the assignment operator and "," The comma operation level is the lowest! //Comma Operator has the lowest precedence
#
Equal (and) is not equal to the seventh; //that is, == and!=
The above is the detailed content of What is the operator precedence rule in C language?. For more information, please follow other related articles on the PHP Chinese website!

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

PhpStorm Mac version
The latest (2018.2.1) professional PHP integrated development tool

WebStorm Mac version
Useful JavaScript development tools

Atom editor mac version download
The most popular open source editor

Dreamweaver Mac version
Visual web development tools





