Home Backend Development C#.Net Tutorial What is the order of precedence of operators in C language?

What is the order of precedence of operators in C language?

May 08, 2024 pm 12:00 PM
c language arrangement Bit shift operator

C 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

What is the order of precedence of operators in C language?

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)
5. Relational operator

< (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 AND assignment)
    |= (logical OR 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!

Statement of this Website
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

Hot Article Tags

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

Usage of typedef struct in c language Usage of typedef struct in c language May 09, 2024 am 10:15 AM

Usage of typedef struct in c language

How to check traffic on Apple mobile phone How to check traffic on Apple mobile phone May 09, 2024 pm 06:00 PM

How to check traffic on Apple mobile phone

What does real mean in c language What does real mean in c language May 09, 2024 pm 12:06 PM

What does real mean in c language

How to implement the power function in C language How to implement the power function in C language May 09, 2024 pm 11:33 PM

How to implement the power function in C language

What to do if there is an error in scanf in C language What to do if there is an error in scanf in C language May 09, 2024 am 11:39 AM

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

How to use ElemType in c language How to use ElemType in c language May 09, 2024 pm 12:03 PM

How to use ElemType in c language

The role of scanfs in c language The role of scanfs in c language May 09, 2024 am 11:30 AM

The role of scanfs in c language

What are the top ten virtual currency trading platforms? Ranking of the top ten virtual currency trading platforms in the world What are the top ten virtual currency trading platforms? Ranking of the top ten virtual currency trading platforms in the world Feb 20, 2025 pm 02:15 PM

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

See all articles