Operator _ and _ operator priority, operator priority
Mathematical operators (7 ):
+,-, *,/, %, ++, And ,--
1 · % is the remainder operator, for example: 3% 2 = 1 8% 3 = 2
2. ++ and -- are the auto-increment 1 and auto-increment 1 operators.
3. I ++ and I both add 1 operations. For example, I ++ and ++ I are equal to I = I + 1 (I = I ++ and I = ++ I have different meanings than I ++ and I + I, (it can be understood that the plus sign first adds the 1 operation and then the value assignment, and the plus sign first adds the value to the 1 operation. For example, int I = 6; I = ++ I; the result is 7, I = I ++; the result is 6 .))
Relational operators:
= ,! =, <,>, <=,> =
Logical operators (common and boolean operators ):
& (Logical and), | (logical or ),! (Non-logical)
&: True only when all conditions are met.
|: True if one condition is met.
! : The highest level in logical operators.
Conditional OPERATOR :? :
Int I;
String s = (relational operation )? (1) :( 2 );
(If the conditions are met, output within 1 bracket; if the conditions are not met, output within 2 brackets)
Computing priority [from top to bottom]
!
(Arithmetic operation level)
++, -- (Prefix)
*,/, %
+ ,-
(Relational operators)
<,>, <=,> =
= ,! =
(Logical operators)
&&
|
! : The highest level in logical operators.
Computing priority example
Int I = 5;
Int s = int. Parse (Console. ReadLine (); // The keyboard accepts integer s.
Bool B =! (S> 5) & (s> = (1 + 2*3-(I ++ )));
Bool B =! (S> 5) & (s> = (1 + 2*3-(-- I )));
Bool B =! (S> 5) & amp; s> = 1 + 2*3--- I;
Bool B =! (S> 5) & amp; s> = 1 + 2*3-(-- I)/2;
Priority of Relational operators, logical operators, and other operators in C Language
C language operator number
Level 1 Priority left combination
() Parentheses
[] Subscript operator
-> Pointer to struct member operators
. Struct member Operator
Level 2 priority right combination
! Logical non-Operator
~ Bitwise Inverse Operator
++ Auto-increment operator
-- Auto-subtraction Operator
-Minus sign Operator
(Type) type conversion Operator
* Pointer Operators
& Addresses and operators
Sizeof length Operator
Level 3 priority left combination
* Multiplication Operator
/Division Operator
% Remainder Operator
Level 4 priority left combination
+ Addition Operators
-Subtraction Operator
Level 5 priority left combination
<Left shift operator
> Right shift operator
Level 6 priority left combination
<, <=,>,> = Relational operators
Level 7 Priority left combination
= Equals Operator
! = Not equal to operator
Level 8 priority left combination
& Bitwise AND operator
Level 9 Priority left combination
^ Bitwise OR operator
Level 10 priority left combination
| Bitwise OR operator
Level 11 priority left combination
& Logic and operators
Level 12 priority left combination
| Logic or operator
Level 13 priority right combination
? : Conditional Operators
Level 14 priority right combination
= + =-= * =/= % = ^=|=<<=> = All value assignment operators
Level 15 priority left combination
, Comma Operator
In C language, who has the highest priority between conditional operators and logical operators?
!
Arithmetic Operators
Relational operators ("=", "! = "Less than" <, <=,>,> = ")
&&
‖
Conditional Operators
Value assignment operator