/ / Program structure in Pascal: programming for beginners

The structure of the Pascal program: programming for beginners

The most accessible programming language forbeginner is pascal. This is due at least to the fact that it is studied in the upper grades of secondary schools, as well as in the first courses at the university. It is used as a base for learning many other languages. However, it is not rational to use it as the main one to develop it now, since the technical equipment has gone far ahead.

Now there are a lot of fundswhich preserve syntax. They differ only in the programming environment of such a language as Pascal. The program structure will be studied during the article. As a rule, familiarity with programming begins with the program "Hello world!".

program structure in pascal

History of language

Pascal came into being in 1970 thanks tooddly enough, Niklaus Virtue. The name of the language was given in honor of Blaise Pascal - a great man originally from France. This is justified by the fact that the scientist created the world's first car that was able to add and subtract numbers.

The development of the language was carried out from 1968 to 1969.The first mention appeared in 1970. The creator, introducing his “child,” focused on the programming style, as well as on data entry in Pascal. The program structure was also developed by Wirth. It has simple syntax and semantics. The direct descendant of Pascal is the Modula-2 language. Its developer also became Wirth.

Grammar rules

It should be noted that the structure of the program is not so complicated in this language. In Pascal, the author laid the use of only three main points - the title, description and operator.

  1. HeadlineHere you must specify the name of the program, but this item is not the main one. It is created only at the request of the developer. For the most part, it depends on the programming environment. Turbo Pascal doesn't need it. But in the ETH it is necessary to create a string. It is allowed to use only numbers, letters and underscore "_".
  2. Description. This block lists all available variables (arrays), labels, etc.
  3. Operator. The structure of the program in Pascal includes a description of the operators in brackets BEGIN-END.

How many will be in one line,irrelevant. The main thing - after the end of each team to put a special character - a semicolon. In addition, the language is case-insensitive: there is no difference between the operator Var, vAr and vaR.

pascal program structure

Syntax and semantics

The main value when working with a programming environment is the alphabet. It should be remembered that it consists of:

  • Latin characters, both lowercase and uppercase;
  • space;
  • underscore;
  • Arabic type numbers;
  • mathematical signs;
  • delimiters (their list includes a period, comma, etc.);
  • specifiers;
  • service words (operators).

The structure of the program on Turbo Pascal is nothingdifferent from the structure on PascalABC. The difference is in their external data, nothing more. When specifying a name for a variable and other types, it is necessary to remember that the name should not begin with a number, the underscore can be in any position, and only alphabetic characters are allowed from letter symbols.

Comments to the lines are enclosed in either braces or in round with an asterisk: (* .. *).

Data types

The structure of the program in Pascal also implies the consideration of such objects as data types. They are of three types:

  1. logical (true and false);
  2. numeric (Arabic numbers);
  3. character (use a, b, c, etc.).

At the same time, the second type is divided into subtypes:whole and real. They correspond to certain operators: Integer and Real, respectively. Symbols are also divided into single characters and strings. This refers to data types such as (in the first case) the number 1, the letter a or A, and (in the second) whole phrases or expression. In the program they are recorded under the names Char and Spring.

program structure in pascal

Values ​​also have their own classification.They are divided into constants and variables. The difference between them is significant. The first implies the meaning of a letter that does not change during the execution of a program. Variables are assigned a value during execution with the help of a special sign - a colon.

Comments

In order to achieve a complete understandingprogram and all its processes, the comment function is used. They, as already discussed above, are placed in braces. This is especially important if looking at the novice code. Because, using this option, you can easily find an error in the already finished program, based on what is written in the comments. Moreover, they will help the developer to quickly figure out the provisioning code over time.

The structure of the program in Pascal allowsassign comments to the data structure specified in the second block. There you need to enter the text, which will contain the purpose of each operator and how it is used in the future.

A beginner will be helped to navigate in the brackets BEGIN-END comment next to them. This will be especially useful in a cycle oriented program. So it will be easier to understand which block of statements is completed.

Comments are not read by the programming environment, so they can occupy any number of time and are not limited in letters.

program structure on turbo pascal

Punctuation

The structure of the program in Pascal has its ownpunctuation, however, is not surprising. The most used character is a semicolon. It is placed after each description of the blocks Label, Type, Const, Var, etc., but the sign is not needed after the word being defined. After Begin it is not installed; after the END is put only if the program is not yet finished. In the code where there are loops and, respectively, use Then and Else, after these words a semicolon is not needed.

At the end of the program after the END, you must set the period, otherwise the programming environment will not understand that the code has ended.

pascal program structure

Input and output data

The structure of the program in Pascal allows you to enter data in three different ways. Among them:

  • With the help of Readln, Read.
  • Using the assignment character - the colon.
  • Constant. In this case, the data is entered in the var parameter.

The output of the received information can be made atusing a bunch of operators Write and Writeln. In some cases, it may be absent, but this only means that it is already built into the method of production.