The assignment operator (=) in C is used to copy a value to another variable. In addition, C provides other assignment operators for combining assignment operations, such as = (additive assignment), -= (subtractive assignment), and *= (multiplicative assignment).
Assignment in c
In C, the assignment operator is used to copy the value of one variable to another in a variable. The assignment operator is =
.
Basic syntax
<code class="cpp">变量 = 值;</code>
For example:
<code class="cpp">int x = 10;</code>
This will change the variablex## The value of # is set to
10.
Assigned to the reference
If the variable is a reference, the assignment operator will modify the referenced target variable value. For example:<code class="cpp">int& y = x; y = 20;</code>
x to
20.
Other assignment operators
In addition to the basic assignment operators, C also has several other assignment operators for combined assignment operations: (Additional assignment)
(subtraction assignment)
(multiplication assignment)
(division assignment)
(modulo assignment)
(left shift assignment)
(right shift assignment)
(bitwise AND assignment)
(bitwise OR Assignment)
(Bitwise XOR assignment)
<code class="cpp">x += 5; // 等同于 x = x + 5</code>
The above is the detailed content of What symbols are used in c++?. For more information, please follow other related articles on the PHP Chinese website!