ComputersSoftware

The structure of the Pascal program: programming for beginners

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

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

History of the language

In the light of Pascal appeared in 1970 thanks, oddly enough, to Niklaus Wirt. The name is given in honor of Blaise Pascal - a great man originally from France. This is justified by the fact that the scientist created the first machine in the world, which was able to add and subtract numbers.

The development of the language was conducted from 1968 to 1969. The first mention appeared in 1970. The creator, presenting his "child", emphasized the style of programming, as well as the input of data in Pascal. The structure of the program was also developed by Wirth. It has a simple syntax and semantics. The direct "descendant" of Pascal is the language of "Modula-2". Wirth was also its developer.

Grammar rules

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

  1. Header. Here you need to specify the name of the program, but this item is not the main one. It is created only if the developer wants. Mostly it depends on the programming environment. In Turbo Pascal it is not needed. But in ETH it is necessary to create a string without fail. Only numbers, letters and the underscore "_" are allowed.
  2. Description. This block specifies all available variables (arrays), labels, and so on.
  3. Operator. The structure of the Pascal program includes the description of the operators in brackets BEGIN-END.

The fact that they will be on the same line does not matter. The main thing - after the end of each team put a special symbol - a semicolon. In addition, the language is insensitive to the register: there is no difference between the operator Var, vAr and vaR.

Syntax and semantics

The main role in working with the programming environment is played by the alphabet. It should be remembered that it consists of:

  • Latin characters, both lowercase and uppercase;
  • A space;
  • Underscore;
  • Arabic numerals ;
  • Mathematical signs;
  • Limiters (their list includes a point, comma, etc.);
  • Specifiers;
  • Service words (operators).

The structure of the program on Turbo Pascal is no different from the structure on PascalABC. The difference is in their external data, nothing more. 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 stand in any position, and from the alphabetic symbols only letters of the Latin alphabet are allowed .

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

Data types

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

  1. Logical (truth and falsehood);
  2. Numeric (Arabic numerals);
  3. Symbolic (using a, b, c, etc.).

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

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 the letter, which does not change during the execution of the program. And variables are assigned a value in the course of execution using a special character - a colon.

Comments

In order to achieve a complete understanding of the program and all its processes, the comment function is used. They, as already mentioned above, are placed in curly brackets. This is especially important if you are viewing a newbie code. Because using this option, you can easily find an error in an already finished program, relying on what is written in the comments. Moreover, they will help the developer to quickly understand the security code.

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

Beginners will be guided in brackets BEGIN-END comment next to them. Especially it will be useful in a program oriented to cycles. So it will be easier to understand which block of operators is complete.

Comments can not be read by the programming environment, so they can borrow any number of dates and are not limited in alphabetical order.

Punctuation

The structure of the program in Pascal has its own punctuation, however, it is not surprising. The most used sign 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 most determined word. After Begin it is not installed; After END is put only in the event that the program is not yet completed. In code where there are loops and, accordingly, are used by Then and Else, after these words a semicolon is not needed.

At the end of the program, after END, you need to set a point, otherwise the programming environment will not understand that the code is completed.

Input and output of data

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

  • Using Readln, Read.
  • Using an assignment symbol, use a colon.
  • Constant. In this case, the data is entered in the var parameter.

The output of the received information can be made using the binding of the Write and Writeln statements. In some cases, it may be absent, but this only means that it is already embedded in the method of receipt.

Similar articles

 

 

 

 

Trending Now

 

 

 

 

Newest

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