This section contains 421 words (approx. 2 pages at 300 words per page) |
The assignment operator in a computer language takes the value of an expression and copies it to a variable. In most languages it is denoted by the familiar mathematical symbol "=", but in some languages, like Pascal, it is denoted by the symbol ":=", which roughly means "becomes equal to." To distinguish "assignment" from "equivalence" (which in mathematics both use "="), most programming languages use the symbol "==". So "a = b" makes "a" take on the value of "b"; "a == b" checks to see if "a" and "b" are equal.
In general the semantics of the assignment operator is: modifiable object = expression. The value of the expression is placed in the modifiable object's data area. A typical example of valid assignment statements in C, C++, and Java is:
- int myInt = 3;
- int myOtherInt = myInt;
The second form of assignment operator is the "compound assignment," which takes the form: modifiable object
This section contains 421 words (approx. 2 pages at 300 words per page) |