Home > Backend Development > C#.Net Tutorial > Priority order table of operators in c language

Priority order table of operators in c language

下次还敢
Release: 2024-04-29 19:36:15
Original
847 people have browsed it

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 (=)

Priority order table of operators in c language

# 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

PriorityOperatorHighestBrackets ()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
Operators with higher precedence are executed before operators with lower precedence.

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.
  • Example
  • <code class="c">a + b * c;</code>
    Copy after login
  • Because multiplication * has a higher precedence than addition , the expression will perform the multiplication first and then the addition.
<code class="c">(a + b) * c;</code>
Copy after login

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!

Related labels:
source:php.cn
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
Latest Articles by Author
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template