Assignment operator

Assignment operator will allow the programmer to set values to a variable. They are written as -


Answer = 1 + 2
					
					

The = sign does not mean =. Rather it is called assignment. Assignment will copy the result of the expression on the right into the variable on the left.


1 + 2 = Answer
					
					

The above code is not valid. This is because it is trying to copy the contents of the variable Answer into 1 + 2 which does not make sense.

A lot of languages try and make this less ambigious. Java and C will use == for equals and = for equals. Some languages would write Answer <- 1 + 2 or even Answer :- 1 + 2.