Assignment Operator

What Does Assignment Operator Mean?

An assignment operator, in the context of the C programming language, is a basic component denoted as “=”. This operator assigns the values on the right-hand side of the operand to the left-hand side.

Advertisements

An assignment operator requires the value of expressions to be well defined and ensures that variables represent an entity that can be modified. Assignment operators also permit the same variable to hold different values at different stages of program execution. This makes assignment operators devoid of referential transparency, where procedures are supposed to return the same results for a particular set of inputs at a given time.

Techopedia Explains Assignment Operator

Assignment operators are basic components of imperative programming such as C, where several values are associated with variable names at different stages of a program’s execution. For instance, consider the code set:

int x=25;
double y;
x=50;

In this set of statements, the variable “x” is initially assigned the value 25. Internally, a memory location is reserved for x, holding value 25. In the third statement, however, the same variable x is assigned another value. Therefore, an output of value x after the execution of all the three statements represents 50. At the machine level, assignment is executed using operations such as MOVE and STORE.

Assignment operators also allow chained assignment of values. For instance, the expression a=b=c=50, assigns the value 50 to a, b and c. This is referred to as chained assignment.

Assignment operators used along with binary operators are called compound assignment operators. They perform a binary operator operation on both operands and store the output of the operation in the left operand.

Advertisements

Related Terms

Latest Database Terms

Related Reading

Margaret Rouse

Margaret Rouse is an award-winning technical writer and teacher known for her ability to explain complex technical subjects to a non-technical, business audience. Over the past twenty years her explanations have appeared on TechTarget websites and she's been cited as an authority in articles by the New York Times, Time Magazine, USA Today, ZDNet, PC Magazine and Discovery Magazine.Margaret's idea of a fun day is helping IT and business professionals learn to speak each other’s highly specialized languages. If you have a suggestion for a new definition or how to improve a technical explanation, please email Margaret or contact her…