Stop Ransomware Mid-Flight

Assignment Operator

Definition - 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.

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;

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.

This definition was written in the context of C Programming Language
Share this: