Operating on variables
Operators apply simple operations such as addition and multiplication to operands such as variables and literal values. They usually return a new value that is the result of the operation and that can be assigned to a variable.
Most operators are binary, meaning that they work on two operands, as shown in the following pseudocode:
var resultOfOperation = firstOperand operator secondOperand;
Examples of binary operators include adding and multiplying, as shown in the following code:
int x = 5;
int y = 3;
int resultOfAdding = x + y;
int resultOfMultiplying = x * y;
Some operators are unary, meaning they work on a single operand, and can apply before or after the operand, as shown in the following pseudocode:
var resultOfOperationAfter = onlyOperand operator;
var resultOfOperationBefore = operator onlyOperand;
Examples of unary operators include incrementors and retrieving a type or its size in bytes, as shown in the following code...