The item on the left of the value assignment operator must be the name of a variable. Example: 2002 = BMW; error 1. the multiplication and division operator is higher than the addition and subtraction operator, and the operator priority is the same from left to right. 2. The priority of the value assignment operator is only higher than that of the comma operator. The combination direction is from right to left. Note: The assignment operator, condition operator, and single object operator are operated from right to left, and other operators are operated from left to right.
++
1. int A = 1; int B = 2; B + A ++ = 3, that is, the first operation is followed by a = 2, B = 2; B + (++) = 4; that is, first add and then calculate a = 2, B = 2B ++ A = 3; that is, (B ++) + A = 3, A = 1, B = 3; int A = 1;
Int B = 2;
Int c = (a ++) + (A ++); // warning reason: multiple new modifications
Printf ("% d, % d, % d \ n", A, B, C );
-Expression similar to ++: The expression has a return value. For example, 6 + (C = 3 + 8) is valid because there are two word expressions, each of which has a value and the result is 17, but it is not recommended to use the statement: minimum unit of program execution, ending with a semicolon (semicolon. Example: Legs = 4 expression legs = 4; statement priority
Priority |
Description |
Operator |
1 |
Brackets |
(), [] |
2 |
Plus or minus sign |
+ ,- |
3 |
Auto-increment and auto-increment, not |
++ ,--,! |
4 |
Multiplication, division, and remainder |
*,/, % |
5 |
Addition and subtraction |
+ ,- |
6 |
Shift operation |
<,>,> |
7 |
Size relationship |
]>,> =, <, <= |
8 |
Equality |
= ,! = |
9 |
Bitwise AND |
& |
10 |
Bitwise OR |
^ |
11 |
By bit or |
| |
12 |
Logic and |
&& |
13 |
Logic or |
| |
14 |
Conditional operation |
? : |
15 |
Value assignment |
=, + =,-=, * =,/=, % = |
16 |
Bit value assignment |
& =, | =, <=, >>=, >>>> = |
Operators (Value assignment, auto-increment and auto-subtraction), expressions, statements, and priority tables