Last Updated:

Standard Pascal features

Therefore, there is no point in writing the same algorithm to solve them, if it has long been known and written by programmers. Such algorithms are presented in the form of modules and functions, and then applied in programs that are currently being written.

A procedure or function may already be part of a programming language or a module that you want to "connect" to a program. Next, here are the standard functions of the Pascal programming language.

Standard Pascal features


Basic or arithmetic functions


FunctionDestinationResult Type
abs (x)the absolute value of the argumentmatches the type of the argument
sqr (x)argument squarematches the type of the argument
sqrt (x)square root of the argumentreal
cos (x)argument cosinereal
sin (x)argument sinereal
arctan (x)arctangents of the argumentreal
exp (x)exreal
ln (x)natural logarithmreal
int (x)integer part of a numberreal
frac (x)fractional part of a numberreal

Type Conversion Functions

round (x)- Rounds the real number to the nearest integer.
trunc (x)— gives out the whole part of the real number, discarding the fractional one.

Pascal User-Defined Functions


A function in Pascal is a subroutine that always returns a specific value (unlike a procedure). Therefore, in the body of the function, its name is assigned to the result (computational value), which it returns.

In other words, a function is a subroutine whose output is a certain value.

Functions are used for:

  • conducting the same calculations in different places of the program;
  • To create public libraries of functions.


  • the title begins with the service word function
    word function
  • description of formal parameters (those whose values are passed from program to function):
    description of formal parameters
  • variable parameters — parameters whose values will be available in the main program (they are returned to the program)
    variable parameters
  • the type of result returned by a function through a colon is described at the end of the function header:
    function header
  • A function is called in the body of the main program only if its name is in any expression (the procedure is called separately).
  • Inside a function, you can declare and apply local variables:
    local variables

    Rules for using features in Pascal:

  • to use the function, you must specify it on the right side of the assignment operator;
  • when accessing a function, you need to specify its arguments in parentheses;
  • In the variable description section, it is important to correctly specify the types of variables that you plan to use as a result or aggrument of the function;
  • multiple functions can be accessed in a single expression.

Rules for the application of procedures:

  • To execute a procedure, it must be called in the program as an operator.
  • In the Variable Descriptions section, correctly specify the type of variable that you plan to use as a procedure argument.

Task. Find the values of the expressions:

a) (1+x)2
b) √((1+A)∗5)

c) |a+ bx|

Before you start compiling the program, you need to translate these expressions from the mathematical language to Pascal.

a) (1+x)2 → sqr(1+x)
b) √((1+A)∗5)
 → sqrt((1+A)*5)
c) | A+ bx| → abs(A+b*x)

Now you can proceed to the compilation of the program itself.

Program Primer;
A : word; {since the rooted expression must be positive}
b, x, result : real;
Writeln('Enter variable values (A-positive)');
Result := sqr(1+x);
Writeln (‘sqr(1+x)=’, result);
Result := sqrt((1+A)*5);
Writeln (‘sqrt((1+A)*5)=’, result);
Result := abs(A+b*x);
Writeln (‘abs(A+b*x)=’, result);

Task. Type the program, test its performance, add a comment, save the file, and then print the listing.

Any questions about the material can be asked in the comments. Are you having any difficulties?