ComputersProgramming

Operators Pascal. Pascal programming language

Probably every schoolboy knows a programming language 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 now it has only been 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 the use of 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 a new generation.

Why did they create "Pascal ABS"? There were two important 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 a 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 .NET platform allows you to use some additional functions, as well as programming 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.

General characteristics of operators

Operators in the programming language are necessary in 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 designed 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 below 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, followed by the call parameters. However, the language has procedures that do not have the last element. They are divided into two types in Pascal:

  • Standard (written in the language itself);
  • Custom (created by the programmer).

When you specify a specific set of elements in a row, this or that procedure is used.

Operators ("Pascal"), who are responsible for standard 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.

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

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. As a label, a set of numbers and letters should be used with no signs or spaces. 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 you create a department, you need to know about some of the nuances:

  • All described tags should be used;
  • If the 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, violate the computational process.

Condition operators

A conditional statement, represented by the IF-THEN-ELSE constructs, is used to display branchings 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 action, 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.

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 commands is presented as the only whole.

Selection operator

Because the IF statement is only able to work with 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 variant that follows after the word ELSE or after the CASE statement is executed.

This selection operator in Pascal does not use such 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. Its use is much more convenient, especially if there are 5 or more options. To register permanently IF-THEN will be long, and this is not an easy process.

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 an iterative similar nuance is unknown. The loop is executed until the condition is fulfilled.

Different types and types of cycles can be distinguished 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.

Operators of input-output

Operators of I / O respond to the interaction of the programming environment with the environment. They allow you to enter information and output the result to the screen or to 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 flashing cursor appears on the screen, which is waiting for data input from the person. The difference between 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 part allows you to continue to output data on the next line. If you just specify the operator in the program, an empty period will be displayed. Use this command in this sense is not necessary.

There are also var, close statements. They can not be used if the program does not require it.

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

Similar articles

 

 

 

 

Trending Now

 

 

 

 

Newest

Copyright © 2018 en.birmiss.com. Theme powered by WordPress.