What does the term "Assignment operator" mean?

A type of operator which uses numbers to assign a value to a variable. It is made up of two operands one of which being your variable, or an operand (your variable) and an expression.

For example, if you were to say x = 3 the letter x is your variable and 3 is your operand. When you then ask the computer to show you the value of variable x/code>, it would return 3.

If instead you were to say x = 3 + 5 the letter x is your variable and 3 + 5 is your expression. The value stored in xwould be 8.

Although they vary in how they are written between languages, the assignment operators are roughly as follows:

OperatorExampleDescription
=x = 4 returns 4the left value is equal to the right value
+=x += 3 returns 7 (where x is 4)the left value is equal to the left value added to the right value
-=x-= 10 returns -6 (where x is 4)the left value is equal to the left value subtracted from the right value
*=x *= 7 returns 28 (where x is 4)the left value is equal to the left value multiplied by the right value
/=x /= 3 returns 1.333333333333333 (where x is 4)the left value is equal to the left value divided by the right value
%=x %= 3 returns 1 (where x is 4)the left value is equal to the remainder of the left value divided by the right value

Leave a Reply

Thank you for choosing to leave a comment. Comments may be moderated.