


What is the order of precedence of operators in C language?
May 08, 2024 pm 12:00 PMC language operator precedence sequence: unary operators multiplication and division operators addition and subtraction operators displacement operators relational operators equality operators logical operators conditional operators assignment operators
C language operator precedence sequence
In C language, the precedence of operators determines their order in an expression The order of execution. The higher the operator precedence, the first it is executed.
The following is the order of precedence of C language operators from high to low:
1. Unary operator
- & (address Address)
- (dereference)
- ##(take a positive number)
- (Take a negative number)
! (Logical NOT)- ~ (Bit NOT)
- (Previous Increment)
- -- (pre-decrement)
2. Multiplication and division operators
-
- (Multiplication)
/ (Division) - % (Remainder)
3. Addition and subtraction Operator
- (addition)
- (subtraction)
4. Bit shift operator
- << (left shift)
- ##( Shift right)
< (less than)
- (Greater than)
- <= (Less than or equal to)
- = (Greater than or equal to)
- ##6. Equality operator
##== (equal to)
!= (not equal to)- 7 . Logical operators
&& (logical AND)
|| (logical OR)- ! (logical NOT)
- 8. Conditional operator (ternary operator)
? :
- 9. Assignment operator
= (assignment)
= (plus assignment)- -= (subtraction assignment)
- *= (multiplication assignment)
- /= (division assignment)
- %= (remainder assignment)
- <<= (left shift assignment)
- = (right shift assignment)
-
|= (logical OR assignment)&= (logical AND assignment)
- ^= (EXIST Or assignment)
- Note:
Operators with the same priority are executed in order from left to right.
You can use parentheses to change the execution order of operators.The above is the detailed content of What is the order of precedence of operators in C language?. For more information, please follow other related articles on the PHP Chinese website!

Hot Article

Hot tools Tags

Hot Article

Hot Article Tags

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

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

Hot Topics

Usage of typedef struct in c language

How to check traffic on Apple mobile phone

How to implement the power function in C language

What to do if there is an error in scanf in C language

What are the top ten virtual currency trading platforms? Ranking of the top ten virtual currency trading platforms in the world
