Skip to content

Operators

Operators

Language operators describe some algorithmic operations that must be executed to accomplish a task. The program body is a sequence of such operators. Operators following one by one are separated by semicolons.

OperatorDescription
Compound operator {}One or more operators of any type, enclosed in curly braces {}
Expression operator (;)Any expression that ends with a semicolon (;)
return operatorTerminates the current function and returns control to the calling program
if-else conditional operatorIs used when it’s necessary to make a choice
?: conditional operatorA simple analog of the if-else conditional operator
switch selection operatorPasses control to the operator, which corresponds to the expression value
while loop operatorPerforms an operator until the expression checked becomes false. The expression is checked before each iteration
for loop operatorPerforms an operator until the expression checked becomes false. The expression is checked before each iteration
do-while loop operatorPerforms an operator until the expression checked becomes false. The end condition is checked, after each loop. The loop body is always executed at least once.
break operatorTerminates the execution of the nearest attached external operator switch, while, do-while or for
continue operatorPasses control to the beginning of the nearest external loop operator while, do-while or for
new operatorCreates an object of the appropriate size and returns a descriptor of the created object.
delete operatorDeletes the object created by the new operator

One operator can occupy one or more lines. Two or more operators can be located in the same line. Operators that control over the execution order (if, if-else, switch, while and for), can be nested into each other.

Example:

if(Month() == 12)
  if(Day() == 31) Print("Happy New Year!");

See also

Initialization of Variables, Visibility Scope and Lifetime of Variables, Creating and Deleting Objects

Last updated on