/ / Operators "Pascal". Pascal programming language

Operators Pascal. Pascal programming language

Probably every schoolboy knows the languageprogramming, which is called "Pascal". What is it? For a long time this language has become dead, because it is used only in schools for teaching students and is considered a 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 it is now only preserved, in fact, for educational purposes. The first thing that attracts potential programmers in Pascal is the ability to write, preserving the properties of the English language, rather than racking one's brains over using special schemes that are adopted in languages ​​like C.

Created "Pascal" by 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 language "Pascal" is "Modula-2". The latter is an improved version.

Programming system

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

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

  • obsolete systems of the original language;
  • desire to form a more modern and integrated programming environment.

The language of Pascal ABC includes the system of classical "Pascal", elements of "Delphi" and its own extensions. He appeared in 2002.

There is also an eponymous compiler, which is a powerful and modern programming environment. It can work on Linux, macOS, and Windows.

The platform.NET allows you to use some additional functions, and also to program in structural, object-oriented and functional styles. The author of this language was Mikhalkovich. Influence on it was rendered not only by Pascal and Delphi, but also by C # and Python.

operators pascal

General characteristics of operators

Operators in the programming language are necessary forIn order 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 arranged in such a way that all operators consist of special service words. Separate commands between themselves and other elements using a semicolon (;) character. All operators are conditionally divided into groups:

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

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

The procedure operator

This operator is required to call the 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, the language has procedures that do not have the last element. They are divided into "Pascal" into two types:

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

When you specify a specific set of elements in a row, a particular procedure is used.

Operators ("Pascal"), who are responsible forstandard actions, remember fairly easily. 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 you do not need to enter into the first block. These are the tasks read, write and others.

Custom procedures are required beforethe work of the program is created and placed in the descriptions section or in the module. When using the latter option, it should be written to the USES or PROCEDURE section.

pascal abc

The unconditional branch operator

Simple operators are easy to use,including GOTO. In "Pascal" there is a section of labels that allows you to place a certain operator, necessary for the developer, and then refer to it unconditionally. A set of numbers and letters with no signs and spaces should be used as a label. It is separated from the line by a colon (:). Before creating a label, you must specify the names of this element in the LABEL description section.

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

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

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

Pascal output operator

Condition operators

The conditional operator represented by the constructionsIF-THEN-ELSE, used to display branches in which one of the options is necessarily a lie. The computing process will continue on one of the presented options. Conditionally the process is divided into two types:

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

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

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

teams in pascal

The composite operator

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

Selection operator

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

This selection operator does not use Pascalsuch a system of work as IF. There is no explicit verification of the condition. If we consider its work in more detail, we can see that CASE introduces a small dissonance in the program, since the operator ends with the word END, to which there is no pair BEGIN. It is much more convenient to use it, especially if there are 5 or more choices. To register permanently IF-THEN will be long, and this is not an easy process.

main operators pascal

Operators ("Pascal"): cycles

What are cycles? They imply a repetition of some command systems several times until the condition is fully satisfied. Two types of cycles are known in Pascal:

  • cycle with parameter;
  • iterative.

What does each represent?The first (a cycle with a 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 starts.

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

You can distinguish the types and types of cycles with the help of some structures:

  • REPEAT: repetition with a postcondition.
  • WHILE: repetition with precondition.
  • FOR - the 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 operator is that they can be used in a loop with a parameter, and FOR can not be used for repetitions without a parameter.

selection operator in pascal

Operators of input-output

For the interaction of the programming environment withthe environment is the responsibility of input-output operators. They allow you to enter information and display the result on the screen or for printing. 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 flashing cursor appears on the screen, which is waiting for data input from the person. The difference in the performance of the two read and readln operators is small. The latter simply moves the cursor to the next line.

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

There are also operators var, close. They can not be used if that is not required by the program itself.

structured operators

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