Operator classification, precedence
Operator:
First, the mathematical operator:
+,-,*,/,++,--
Example 1:
Example 2:
Example 3:
1. Increment operator : + +
(1) Prefix increment operator
int x=4;
x++;//output, the value of X is 5
Example:
(2) Postfix increment operator
int x=4;
++x;//output, the value of X is 5
The difference between the prefix increment operator and the postfix increment operator:
①int y=++x;
equivalent to x=x+1;
int y=x;
②int y=x++;
equivalent to int y=x;
x=x+1;
2. Decrement operator :--
The same increment operator.
Example:
Two, the relationship operator, a total of 6. Returns only Ture or false.
= =,! =, <,>, <=, >=
Note: A "=" is an assignment, and 2 "= =" means equal
Example:
Three, a total of 3 logical operators.
&& (with) | | (OR)! Non-
Example:
Iv. Assignment operators
=, + =,-=, *=,%=,/=
Example:
Five, the conditional operator ()? ():()
Example: x= (x>12)? (x-12):(x);
If x>12, then x=x-12, otherwise x=x. Judge true, False
C # Language Basics Operators