Last Updated:

Standard Pascal expressions

Pascal's Standard Mathematical Functions
TreatmentResult TypeArgument typeNote
Abs(x)Argument typeReal, integerArgument module
ArcTan(x)RealReal, integerArctangents (meaning in radians)
Cos(x)RealReal, integerCosine, angle in radians
Exp(x)RealReal, integerExponent
Frac(x)RealRealFractional part of a number
Int(x)RealReal, integerInteger part of a number
Ln(x)RealReal, integerLogarithm natural
Sin(x)RealReal, integerSinus, angle in radians
Sqr(x)Argument typeReal, integerArgument square
Sqrt(x)RealReal, integerSquare root
RandomRealNoPseudorandom number in the range [0, 1]
Random(I)IntegerIntegerPseudorandom number in the range [0, I]
Round(x)IntegerRealRound up to the nearest whole
Trunc(x)IntegerRealDiscard the fractional part of a number

The order of calculations in expressions is as follows:

  1. Subexpressions are calculated (in parentheses);
  2. Next, operations with the highest priority are performed. The following priority levels are most commonly used (descending):
    o exponentiation;
    o * , / , div , mod — multiplicative operations;
    o + , — , abs , not — unary operations;
    o +, -; – additive operations;
    o = ,<>, <, >, <=, >= — relationship operations;
    o and, or, not — logical operations;
  3. Operations that have the same priority are performed from left to right.

Although there are no restrictions on the complexity of expressions, expressions that consist of more than seven operands are difficult to understand and read. They are not advised to use.

In Pascal, there is no standard function or exponentiation operation, respectively, such a mathematical identity is used: xy= eylnx. In Pascal, only the standard function for calculating the natural logarithm is used, so the mathematical identity is used: logab= ln b/ln a.

Mathematical expression:

x3/2 — 7x + tg (x+2).
Pascal expression: exp(3*ln(x)/2)-7*x+sin(x+2)/cos(x+2)


Action Operators


Action operators are language tools that allow you to change the state of calculations during program execution. The most elementary action operator is the assignment operator.



a:=15+5; {variable a assignable to a mathematical expression. It is important that the variable a is of numeric type}

Despite its apparent simplicity, the assignment operator has an important algorithmic value.
Assigning a variable to a specific value means placing that value in the variable's box. In addition, each storage box has the following properties:

  1. A mailbox (at any given time) cannot store more than one value.
  2. Each mailbox can only store a value of the same type. Otherwise, an error will occur in the program.
  3. The value in the mailbox will be stored until a new job is placed in the mailbox. Moreover, the previous content will be lost irretrievably.
  4. The value in the mailbox is considered the current value of the corresponding variable. It can be issued from the box as many times as you like, but the contents are unchanged: a copy of the value is issued from the box each time and the original is preserved without any changes.
  5. The contents of all storage boxes are considered undefined at the beginning of the program execution. They can not be considered empty, since these boxes can be used when executing past programs, after which something could be saved.

It is worth considering the empty operator, which is indicated in Pascal by the sign ";". It doesn't do anything. Also in Pascal, the operator of the action is the operator of the procedure. The last of the simplest action statements is the stop statement, which interrupts the program (in Pascal, this is the halt operator).

Data input and output


Keyboard input is performed using the standard read procedure (<the list of input>) or its variety readln (<the list of input>). Input list items—variable names(IDs) that are listed separated by commas. When performing this statement, the user types the necessary sequence of values on the keyboard, separating them with spaces.


read(a,b,c); {wherea,b,c are variables. data entry is performed through a space}
readln(a,b,c); {wherea,b,c are variables. data entry is performed through enter(return of proofreading)}

Data is displayed on the screen using the standard procedure write (<fall lists>) or its variety writeln (<fall list>). The output list can contain variables, expressions, constants, output format. Expressions in lists should be separated by commas.


write(a,b,c); {wherea,b,c are variables. after the data is displayed, the cursor is on the last character}
writeln(a,b,c); {wherea,b,c are variables. after the data is displayed on the screen, the cursor moves to a new line)}

Ending ln in the name of the procedure indicates that the cursor will be moved to the beginning of the next line of the screen.