Operators Pascal. Pascal programming language

Probably every student knows a programming language called Pascal. What is he like? For a long time this language has become dead, because it is used only in schools to educate students and is considered the base. It refers to a simplified version of the Algol language. But, unlike the latter, Pascal can be used to write real programs and even games. Previously, it was quite popular, but now it is preserved only, in fact, for educational purposes. The first thing that attracts potential programmers to Pascal is the ability to write while preserving the properties of the English language, rather than racking their brains over the use of special schemes that are adopted in languages ​​like C.

Created by Pascal Nicklaus Wirth in 1970. The language is named after the scientist Blaise Pascal, who became the father of the world's first machine. She could add two different numbers. The direct descendant of the Pascal language is Modula-2. The latter is an improved version.

Programming system

Pascal ABC is a programming language introduced by an existing system. However, the described is a version of a new generation.

Why did they create Pascal ABS? There were two significant reasons for this:

  • Outdated original language systems
  • desire to create a more modern and integrated programming environment.

The Pascal ABC language includes the classic Pascal system, Delphi elements, and native extensions. He appeared in 2002.

There is also the eponymous compiler, which is a powerful and modern programming environment. It is able to work both on Linux, macOS, and on Windows.

The .NET platform allows you to use some additional functions, as well as program in a structural, object-oriented and functional style. The author of this language was Mikhalkovich. Influence on him had not only Pascal and Delphi, but also C # and Python.

pascal operators

General characteristics of operators

Operators in a programming language are needed to write a program. They make it possible to perform certain functions and algorithms. How are the teams in Pascal different from other elements? The fact that they imply the performance of an action. Pascal is designed in such a way that all operators consist of special service words. Commands are separated between themselves and other elements using the semicolon character (;). All operators are conditionally divided into groups:

  • Simple. Such commands do not contain other elements. These are: assignment operator (colon and equal), unconditional jump procedures (used for labels).
  • Structured. These operators consist of other elements: a compound operator, condition, loop, join operators .

Both groups will be discussed in detail later in the article.

Procedure statement

This operator is required to call a procedure. In order to create a line in the programming environment, you must specify the identifier behind which the call parameters should be located. However, there are procedures in the language that do not have the last element. They in Pascal are divided into two types:

  • standard (spelled out in the language itself);
  • custom (created by the programmer).

When registering a specific set of elements in a line, one or another procedure is involved.

Operators (Pascal) that are responsible for standard actions are easy to remember. It is necessary to write the word uses in the description section and enter a description of the procedure. There are such standard elements that there is no need to enter in the first block. These are the tasks read, write, and others.

User procedures must be created and placed in the description section or module before the program runs. When using the latter option, it should be written to the USES or PROCEDURE section.

pascal abc

Unconditional jump operator

Simple operators are easy to use, including GOTO. Pascal has a label section that allows you to place a specific operator that the developer needs, and later refer to it due to an unconditional transition. A set of numbers and letters without signs and spaces should be used as a label. It is separated from the line by a colon (:). Before creating a label, in the descriptions section of LABEL, you must specify the names of this element.

Before creating a department, you need to know about some of the nuances:

  • all labels described must be used;
  • if elements have names from numbers, then you can not declare them.

Unfortunately or fortunately, the GOTO operator is not used in modern programming languages. This is due to the fact that such systems, working, create the principle of the conveyor. And such operators (Pascal), like GOTO, disrupt the computational process.

pascal output operator

Condition Operators

The conditional statement represented by IF-THEN-ELSE constructs is used to display branches in which one of the options is necessarily false. The computational process will continue according to one of the presented options. Conventionally, the process is divided into two types:

  • fork structure (when there are two options for action, and each leads to its own result);
  • bypass structure (when the second option is incorrect, in which case the program bypasses the result intended for the truth).

The IF-THEN-ELSE construct represents structured statements. These words are official. Moreover, the latter is not subject to mandatory use.

How does the design work? From English, it translates as "if-then-otherwise." If the condition specified by the program is true, then what is written after the word then is satisfied. And if it is incorrect, then what is written after the else or after the line with then is considered valid.

teams in pascal

Compound statement

In order to understand this phrase, you need to know the definition. Compound statements (Pascal) are a set of operations in a written program that are enclosed in BEGIN-END brackets. Due to this, the group of teams is presented as the only integral.

Select statement

Due to the fact that the IF statement can only work with two branches, a CASE selection command was created. There are service words in this system - case, of, end, else. However, the latter may also be absent. Before the statement works, the parameter and its value must be declared. If the selection key matches the selection constants, then the operator that comes after the last is executed. If there is no correctness, then all commands are ignored. The option that comes after the word ELSE or after the CASE statement is executed.

This selection operator in Pascal does not use a work system such as IF. There is no explicit verification of the condition. If we examine its work in more detail, we can see that CASE introduces a slight dissonance into the program, since the statement ends with the word END, to which there is no pair BEGIN. Its use is much more convenient, especially if there are 5 or more options. It will take a long time to prescribe IF-THEN, and this is not a convenient process.

main pascal operators

Operators (Pascal): Loops

What are loops? They mean repeating some command systems several times until the condition is fully satisfied. In Pascal, two types of cycles are known:

  • a loop with a parameter;
  • iterative.

What does each represent? The first (cycle with parameter) always has known parameters. Sometimes it is also called regular. Its main difference is that the number of repetitions of the cycle is known before it begins.

In the iterative, a similar nuance is unknown. The loop is executed until the condition is met.

You can distinguish between types and types of cycles using some structures:

  • REPEAT: repeat with postcondition.
  • WHILE: repetition with a precondition.
  • FOR - account operator. It is used in a loop with a parameter.

The first two options are used for iterative repetition. The main difference between them and the last statement is that they can be used in a loop with a parameter, and FOR cannot be used for repetitions without a parameter.

pascal selection operator

I / O operators

I / O operators are responsible for the interaction of the programming environment with the environment. They allow you to enter information and display the result on screen or print. The read command will allow the user to specify their data in the running program. How does this happen? The program stops for a while, a blinking cursor appears on the screen, which is waiting for data from a person. The difference between the two read and readln statements is small. The latter simply moves the cursor to the next line.

The output operator (Pascal) is write (ln). Particle LN allows you to continue outputting data on the next line. If you simply specify an operator in the program, an empty deadline will be displayed. Using this command in this sense is not necessary.

There are also var, close statements. You can not use them if the program itself does not require it.

structured statements

The main operators (Pascal) are described in the article. They will help you write a better program, they themselves work quite quickly and without failures. Without them, nothing will happen to the future programmer when working with the Pascal language. Programs without operators, alas, cannot be imagined. So, they need to be able to operate. The loop statements may seem complicated, but you should practice and the problems will all disappear. Good luck in your work!


All Articles