Basic operators and expressions in C Language
Types, priorities, and associativity of C Operators
There are many operators and expressions in C language, which are rare in advanced languages. It is precisely the rich operators and expressions that make the C language function perfect. This is also one of the main features of C language.
The operators in C language not only have different priorities, but also have a feature of their combination. In an expression, the order of computing operations involved in the operation must not only comply with the operator priority rules, but also be restricted by the combination of operators, to determine whether the operation is performed from left to right or from right to left. This combination is not available for operators in other advanced languages, so it also increases the complexity of the C language.
Types of operators C-language operators can be divided into the following types:
1. Arithmetic Operators
It is used for various numerical operations. Including addition (+), subtraction (-), multiplication (*), Division (/), remainder (or modulo operation, %), auto-increment (++) and auto-subtraction.
2. Relational operators
Used for comparison. Including greater than (>), less than (<), equal to (=), greater than or equal to (> =), less than or equal to (<=), and not equal (! =.
3. logical operators
Used for logical operations. Including and (&), or (|), non (!) Three.
4. bitwise Operator
The amount involved in the operation, which is calculated in binary bits. Including bitwise AND (&), bitwise OR (|), bitwise non (~) , Bitwise exclusive or (^), left shift (<), right shift (>.
5. Value assignment operator
Used for value assignment, including simple value assignment (=), compound arithmetic value assignment (+ =,-=, * =,/=, % =), and compound bit operation value assignment (& =, |=, ^ =, >>=, <<=) there are 11 types.
6. Conditional Operators
This is a three-object Operator Used for conditional evaluation (? :).
7. Comma Operator
It is used to combine several expressions into one (,).
8. pointer Operators
This operation is used to obtain the content (*) and the address.
9. Number of cell Operators
Used to calculate the number of bytes of the Data Type (sizeof ).
10. Special operators
There are several types of brackets (), subscripts [], and Members (→.