1. Basic operators and expressions
1. Basic operators and expressions
The large number of operators and expressions in C language is rare in high-level languages. It is the rich array of operators and expressions that make C language highly functional. 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 characteristic of their associativity. In an expression, the order in which each operand participates in the operation must not only follow the rules of operator priority, but also be constrained by operator associativity, in order to determine whether to perform the operation from left to right or from right to left. This kind of associativity is not present in operators of other high-level languages, thus increasing the complexity of C language.
The types of operators in C language can be divided into the following categories:
* The arithmetic operator * * is used for various numerical operations. There are seven types including addition (+), subtraction (-), multiplication (), division (/), remainder (or modular operation,%), self addition (++), and self subtraction (-).
** The relational operator * * is used for comparison operations. Including six types: greater than (>), less than (<), equal to (==), greater than or equal to (>=), less than or equal to (&# 60;=), and not equal to (!=).
** Logical operator * *, used for logical operations. Including three types: (&&), (&# 124;&# 124;), and non (!).
** The bitwise operator * * is used to operate on the amount of binary bits involved in the operation. It includes six types: bitwise AND (&), bitwise OR (&# 124;), bitwise NOT (~), bitwise XOR (^), Leftward Shift (<<), Rightward Shift (>>).
** The assignment operator * * is used for assignment operations and is divided into three categories: simple assignment (=), compound arithmetic assignment (+=, -=, *=,/=,%=), and compound bit operation assignment (&=,&# 124;=, ^=,>>=,<&# 60;=), totaling eleven types`
** The conditional operator * * is a trinocular operator used for conditional evaluation (?:).
** The comma operator * * is used to combine several expressions into one expression (,).
* Pointer operator * * is used for two operations: taking content () and taking address (&).
** The byte count operator * * is used to calculate the number of bytes occupied by a data type (sizeof).
** Special operators * *, including parentheses (), subscripts [], etc.