Current location - Training Enrollment Network - Mathematics courses - What are the operational priorities of operators?
What are the operational priorities of operators?
Operator operation priority * * * is divided into 15, with 1 being the highest and 15 being the lowest. ?

The priority decreases from top to bottom, with the top having the highest priority and the comma operator having the lowest priority. The combination order of expressions depends on the priority of various operators in expressions. Operators with high priority are combined first, and operators with low priority are combined later. Operators in the same row have the same priority.

Priority has nothing to do with the evaluation order. Such as a+b&; & ampB*c, although * has the highest priority, the evaluation order of this expression is decreasing from left to right and from top to bottom, with the highest priority at the top and the comma operator having the lowest priority.

In the same priority, according to the combination. Most operators are combined from left to right, and only three priorities are combined from right to left. They are monocular operators, conditional operators and assignment operators.

The C standard defines the following sequence points:

(1) operator &; & amp; Operator ||; Comma operator,; Conditional operator? After the first subexpression of is evaluated.

(2) After evaluating all real parameters in the function call operator ().

(3) At the end of each complete expression. Complete expressions include variable initialization expression, expression statement expression, return statement expression, control expression in if or switch statement, control expression in while or do statement and all three expressions in f or statement.

(4) Before the standard library function returns, after the standard input/output function formats the conversion descriptor, before and after the standard search function and sorting function call the comparison function, and after the parameters are passed.

According to the definition of sequence point, and operator &; & amp; Or operator comma operator conditional operator: the left operand of the four operators belongs to the previous sequence point and the right operand belongs to the latter sequence point, so the evaluation of the left operand of these four operators should be completed before the right operand.