Tech moves fast! Stay ahead of the curve with Techopedia!
Join nearly 200,000 subscribers who receive actionable tech insights from Techopedia.
An assignment is a statement in computer programming that is used to set a value to a variable name. The operator used to do assignment is denoted with an equal sign (=). This operand works by assigning the value on the right-hand side of the operand to the operand on the left-hand side.
It is possible for the same variable to hold different values at different instants of time.
A simple assignment statement could be:
int x = 5
This means that x can only take integer values, and currently a value of 5 is assigned to the variable x.
A single variable can hold various values at different times based on its life span and scope. When a variable which is already assigned a value is assigned another value, the new assignment value overwrites the previously assigned value. The assignment statement also varies from programming language to programming language.