We have already encountered examples of both statements and expressions. So far we have seen simple statements such as subroutine calls like Writeln('Hello World!'). We have also seen compound statements in the form of begin-end blocks. In the rest of this chapter we will encounter structured statements such as loops and conditionals.

Expressions are combinations of variables, constants, operators, and functions that are evaluated according to the order of operations. Expressions are generally identical to what one would expect from basic mathematics with a few slight variations on the apperance of operators. For example in Object Pascal, addition and subtraction are + and - while multiplication and division are * and /. These operators are known as arithmetic operators and they combine with numbers (known as operands) to form arithmetic expressions. There are 6 arithmetic operators in Object Pascal: +, -, *, /, div, and mod. div and mod are special integer division operators that return the whole part of the quotient and the remainder respectively. Thus, 5 div 3 is 1 while 5 mod 3 is 2 (since 5 is divisible by 3 once with a remainder of 2). Parenthesis ( ) are also available, but Object Pascal does not have a native exponent symbol. The six arithmetic operators are known as binary operators because they operate on 2 operands at a time. If + or - are used with a number by themselves such as -3 then they act as unary operators because they effect only one operand.

Strings can also be combined into expressions. The most common string expression is called concatenation in which multiple strings are joined: 'test'+' string' is equivalent to 'test string'.
Excercise 2-5.
Evaluate each of the following expressions.
  1. 3*4+2*(4-1)*7+8/2
  2. 4*3 mod 2 + 14 div 4
  3. 'some text'+2
  4. ''+'some'+' '+'text'+''
  5. --+-3
Boolean expressions are a third type of expression that are equally as important as arithmetic and string expressions. Boolean expressions can have only 1 of 2 values: True or False. Boolean expressions will be used later in Unit 1 to control the flow of instruction execution. The Boolean operators in Object Pascal are fairly intuitive: not, and, or, xor. not negates the truth value of the expression. So not True evaluates to False. and requires that both operators be True in order to evaluate to True, otherwise it returns False. So True and False evaluates to False while True and True evaluates to "True". or will evaluate to True if either operator is True. Thus, unlike and, True or False evaluates to True. xor evaluates to True if and only if one value is True and the other is False. Thus, True xor False evaluates to True while True xor True evaluates to False. The Boolean operators obey the same operator precedence as addition and subtraction. 
Excercise 2-6.
Evaluate each of the following Boolean expressions.
  1. True and False and True xor True
  2. not ((True or False) and (False xor False)
The fourth type of expression is the relational expression. This is where arithmetic and string expressions meet Boolean expressions. Relational expressions always evaluate to True or False but they take numbers or strings as operands. For example, the expression 5 = 3 is False while the expression 5 > 3 is true. There are 6 relational operators in Object Pascal: equal =, not equal <>, less than <, greater than >, less than or equal <=, and greater than or equal >=. Both string and number operands are allowed but operands used simultaneously must be logically compatible: 'test' > 3 will not compile but 2.3 > 3 will. All relational operators have the same precedence as an equal sign in mathematics (i.e., the highest) which means that they are evaluated last.
Excercise 2-7.
Evaluate each of the following expressions.
  1. (3 > 2) or (2+1<>4) <> not (2*5 > -1)
  2. 'test' < 'test3'
One of the key differences between statements and expressions in Object Pascal is that statements can stand alone in a begin-end block while expressions must be contained inside of statements. In other words, the following code will not compile:
program Workspace;
begin
  -11.5+1.5
end.
The statements inside of a begin-end compound statement are said to compose a statement list. As you may have already noticed, in Object Pascal, statements in a statement list must always be separated by semicolons. Leaving off a semicolon from the end of a line is one of the most common mistakes in coding and can occasionally lead to strange error messages from the compiler. Thus, it is always something to check for if your code will not compile.