2. Assignment Operators
Assignment operators assign values.
For the AQA exam board, the most common pseudocode assignment operator is the back pointing arrow
which is the equivalent of =
An operator always acts on at least one item, which is called the 'argument' of the operator.
In the case of assignment, ? copies the value of its right argument into the argument on its left.
MyVariable2
This assigns the value 2 to the variable named 'MyVariable'.
The assignment operator can also copy a value from one variable to another. For example
MyVariableAnotherVariable
Because of the right-to-left rule, that statement is going to copy the value of the right variable AnotherVariable into the variable on the left MyVariable - not the other way around.
Because of the assigment operator, you can write code to carry out calculations and assign the result to a single variable, like this
MyVariableAnotherVariable + 3 + Age
In the code above the + operator is adding up the arguments on the right hand side of ?, then the ? operator assigns the result to the argument on its left: MyVariable.
In many actual programming languages, the symbol "=" is used for assignment. But your exams will always use "
".
Challenge see if you can find out one extra fact on this topic that we haven't already told you
Click on this link: What are assignment operators?
