Most common in mathematics numeric types- This whole numbers that represent an infinite number of discrete values, and valid numbers that represent an unlimited continuum of values.

Description of Pascal's numeric data types (integers)

Within the same language, different subsets of the set of integers can be implemented. The range of possible values ​​of integer numeric types depends on their internal representation, which can be one, two, or four bytes. Thus, in Pascal 7.0 the following integer numeric data types are used:

With whole numeric data types Pascal can perform the following operations:

  • Arithmetic:
    addition(+);
    subtraction(-);
    multiplication(*);
    remainder of division (mod);
    exponentiation;
    unary plus (+);
    unary minus (-).
  • Relation operations:
    equality relation (=);
    inequality relation (<>);
    ratio is less (<);
    ratio greater than (>);
    relation not less than (>=);
    attitude no more (<=).

When acting with integer numeric data types the type of the result will correspond to the type of the operands, and if the operands are of different integer types, to the type of the operand that has the maximum power (maximum range of values). Possible overflow of the result is not controlled in any way (it is important!) , which may lead to errors.

Particular attention should be paid to the division operation of integer numeric data types. Pascal allows two division operations, which are denoted accordingly "/" And div. You need to know that the result of division "/" is not an integer, but real number(this is true even if you divide 8 by 2, i.e. 8/2=4.0). The division div is integer division, i.e. result type is integer.

Description of Pascal's numeric data types (reals)

The real numeric data type refers to a subset of real numbers that can be represented in the so-called floating point format with a fixed number of digits. With floating point, each numeric data type is represented as two groups of digits. The first group of numbers is called the mantissa, the second is the exponent. In general, a numeric data type in floating point form can be represented as follows: X= (+|-)MP (+ | -) r, where M is the mantissa of the number; r – number order (r – integer); P – base of the number system. For example, for the decimal base, the representation 2E-1 (here E is the base of the decimal number system) will look like: 2*10 -1 =0.2, and the representation 1.234E5 will correspond to: 1.234*10 5 =123400.0.

Pascal uses the following types of real numbers, which define an arbitrary number only with some finite precision depending on the internal format of the real number:

When describing a real variable of type real, a variable of 4 bytes will be created in the computer memory. In this case, 3 bytes will be given for the mantissa, and one byte for the order.

The following operations can be performed on real numeric data types:

  • Arithmetic:
    addition (+);
    subtraction(-);
    multiplication(*);
    division(/);
    exponentiation;
    unary plus (+);
    unary minus (-).
  • Relation operations:
    inequality relation (<>);
    ratio is less (<);
    ratio greater than (>);
    relation not less than (>=);
    attitude no more (<=).

As you can see, Pascal is characterized by a rich range of real types, but access to numeric data types single, double And extended only possible under special compilation modes. These numeric data types are designed for hardware support for floating-point arithmetic, and to use them effectively, your PC must include a math coprocessor.

The numeric data type occupies a special position in Pascal. comp, which is treated as a real number without exponential and fractional parts. Actually, comp is a “large” signed integer that retains 19..20 significant decimal digits. At the same time, the numeric data type comp in expressions it is fully compatible with other real types: all real operations are defined on it, it can be used as an argument to mathematical functions, etc.

About converting Pascal's numeric data types

In Pascal, implicit (automatic) conversions of numeric data types are almost impossible. An exception is made only for the type integer, which is allowed to be used in expressions like real. For example, if the variables are declared like this:

Var X: integer; Y: real;

That's the operator

will be syntactically correct, although there is an integer expression to the right of the assignment sign and a real variable to the left, the compiler will convert numeric data types automatically. The reverse conversion is automatically type real in type integer impossible in Pascal. Let's remember how many bytes are allocated for type variables integer And real: for integer data type integer 2 bytes of memory are allocated, and for real - 6 bytes. To convert real V integer There are two built-in functions: round(x) rounds real x to the nearest integer, trunc(x) truncates a real number by discarding the fractional part.

Each type denotes a subset of integers:

Type Range Format
ShortInt -128..127 Signed 8 bits
Integer -32768.. Signed 16 bits
LongInt -2147483648.. Signed 32 bits
Byte 0..255 Unsigned 8 bits
Word 0..65535 Unsigned 16 bits

All integer types are ordinal. The maximum values ​​of Integer and LongInt correspond to the constants MaxInt and MaxLongInt. The maximum and minimum values ​​of other integer types can be obtained using the Low and High functions.

Ada

Interfaces package:

This package declares integer types with ranges that are independent of the compiler and operating environment.

Type Range Format
Integer_8 -128..127 Signed 8 bits
Integer_16 -32768..32767 Signed 16 bits
Integer_32 -2147483648..2147483647 Signed 32 bits
Integer_64 -2**63 .. 2**63 - 1 Signed 64 bits
Unsigned_8 0..255 Unsigned 8 bits
Unsigned_16 0..65535 Unsigned 16 bits
Unsigned_32 0..4294967296 Unsigned 32 bits
Unsigned_64 0 .. 2**64 - 1 Unsigned 64 bits

Standard package (connects automatically):

This package defines standard integer types. According to the standard, the range of each subsequent type should not be narrower than the previous one. In addition, two of these types have explicit minimum bit limits.

Type Not narrower than... Usually is...
Short_Short_Integer Integer_8
Short_Integer Integer_16
Integer Integer_16 Integer_32
Long_Integer Integer_32 Integer_32
Long_Long_Integer Integer_64

Despite the fact that I wrote down the bit depth of each type in the right column, I recommend using only Integer and Long_Integer. For all other bit sizes, Integer_x types are preferable. The compiler is like a private detective. The more omissions he makes, the less useful he will be. Who knows what bit depths standard types will have on the Win128 platform.

In addition to the indicated types, Standard has frequently used ones:

Natural is Integer range 0 .. Integer"Last;
Positive is Integer range 1 .. Integer"Last;

Ada's type system is better thought out than Borland Pascal. The following program cannot be compiled in Borland Pascal:

programTest_Word;

var
I: Word; (with the best intentions)

begin
for I:= 0 to -1 do ( Constant out of range )
begin
end;
end.

Index -1 is a common occurrence when working with arrays whose starting index is 0. If the array is empty, then the upper bound of the for loop (the length of the array minus one) is exactly -1. Instead of throwing an error, this loop should simply do nothing. In the Ada language such problems will not arise. Use Natural and Positive for your health.

When describing a variable, you must indicate its type. The type of a variable describes the set of values ​​it can take and the actions that can be performed on it. A type declaration specifies an identifier that represents the type.

Simple types are divided into standard (ordinal) and enumerated (restricted).

Standard types

Turbo Pascal has four built-in standard types: integer, real, boolean, and char.

Integer type (integer)

Turbo Pascal has five built-in integer types: shortint, integer, longint, byte, and word. Each type denotes a specific subset of integers, as shown in the following Table.

Built-in integer types.

Range

Format

8 signed bits

16 signed bits

2147483648 +2147483647

32 bit signed

8 bits unsigned

16 bits unsigned

Arithmetic operations on operands of integer type are performed in accordance with the following rules:

  1. An integer constant type is a built-in integer type with the smallest range that includes the value of that integer constant.
  2. In the case of a binary operation (an operation that uses two operands), both operands are converted to their common type before the operation is performed on them. The common type is the built-in integer type, with the smallest range that includes all possible values ​​of both types. For example, the common type for an integer and a byte-length integer is integer, and the common type for an integer and a word-length integer is long integer. The action is performed according to the precision of the generic type and the type of the result is the generic type.
  3. The expression on the right side of the assignment operator is evaluated regardless of the size of the variable on the left.

Operations performed on integers:

“+” - addition

“-“ - subtraction

"*" - multiplication

SQR - squaring

DIV - discards the fractional part after division

MOD - obtaining the integer remainder after division

ABS - number module

RANDOM(X) - obtaining a random number from 0 to X

A:=100 ; b:=60 ; a DIV b result - 1 a MOD b result - 40

Integer type variables are described as follows:

var variable list: type;

For example: var а,р,n:integer;

Real type(real)

The real type is a subset of real numbers that can be represented in floating point format with a fixed number of digits. Writing a value in floating point format typically involves three values ​​- m, b and e - such that m*b e, where b is always 10 and m and e are integer values ​​in the real range. These values ​​of m and e further determine the range and precision of the real type.

There are five types of real types: real, single, double, exnende, comp. Real types vary in the range and precision of the values ​​associated with them

Range and decimal digits for real types

Range

Numbers

2.9x10E-39 to 1.7x10E 38

1.5x10E-45 to 3.4x10E 38

5.0x10E-324 to 1.7x10E 308

3.4x10E-493 to 1.1x10E 403

2E 63 to 2E 63

Operations performed on real numbers:

  • All operations are valid for integers.
  • SQRT(x) is the square root of x.
  • SIN(X), COS(X), ARCTAN(X).
  • LN(X) is the natural logarithm.
  • EXP(X) is the exponent of X (e x).
  • EXP(X*LN(A)) - exponentiation (A x).
  • Type conversion functions:
    • TRUNC(X) - discards the fractional part;
    • ROUND(X) - rounding.
  • Some rules of arithmetic operations:
    • If an arithmetic operation contains numbers of type real and integer, then the result will be of type real.
    • All components of the expression are written on one line.
    • Only parentheses are used.
    • You cannot put two arithmetic signs in a row.

Variables of real type are described as follows:

var variable list: type;

For example:

var d,g,k:real ;

Character type(char)

The char type is any character enclosed in apostrophes. To represent an apostrophe as a character variable, you must enclose it in an apostrophe: ''''.

Each character has its own code and number. The serial numbers of digits 0,1..9 are ordered in ascending order. The serial numbers of the letters are also ordered in ascending order, but do not necessarily follow each other.

The following comparison signs apply to character data:

> , < , >=, <=, <> .

For example: 'A'< ‘W’

Functions that apply to character variables:

  1. ORD(X) - determines the serial number of the symbol X. ord (‘a’) =97 ;
  2. CHR(X) - identifies a character by number. chr(97) =’a’;
  3. PRED(X) - returns the character preceding the X character. pred (‘B’) =’A’;
  4. SUCC(X) - returns the character following the X character. succ (‘A’) =’B’;

Enum type

An enumerated data type is so named because it is specified as a list of constants in a strictly defined order and in a strictly defined quantity. An enumerated type consists of a list of constants. Variables of this type can take the value of any of these constants. The enumeration type description looks like this:

Type<имя типа>=(list of constants) ; Var<имя переменной>:<имя типа>;

Where<список констант>- this is a special type of constants, specified separated by commas and having their own serial number, starting from 0.

For example:

type direction=(north, south, west, east) ; month=(June, July, August, January) ; capacity=(bucket, barrel, canister, tank) ; var rotation:direction; departure:month; volume:capacity; var turn:(north, south, west, east) ; departure: (June, July, August, January) ; volume: (bucket, barrel, canister, tank);

You can perform the following assignment operators:

Rotation:=south; departure:=August; volume:=tank;

but you can't do mixed assignments:

Departure:=south; volume:=August;

The following functions apply to variables of enumerated type:

1. ORD - serial number

2. PRED - previous element

3. SUCC - subsequent element.

PRED (barrel) = bucket; SUCC (south) =west; ORD (July) =1 ;

Variables of an enumerated type can be compared because they are ordered and numbered. So the expressions: north< юг, июнь < январь имеют значения TRUE, а юг>west and tank<бочка значение FАLSE.

Limited type

If a variable does not accept all values ​​of its type, but only within a certain range, then it can be considered a variable of a limited type. Each constrained type is defined by imposing a constraint on the base types.

It is described as follows:

TYPE<имя типа>=constant1 ..constant2

In this case, the following rules must be followed:

  1. Both bounded constants must be of the same type.
  2. Any simple type except real can be used as a base type.
  3. The initial value when defining a limited type must not be greater than the final value.
type index =0 ..63 ; letter=’a’..’z’; var char1,char2:letter; a,g:index ;

You can describe it immediately in the variable description section:

var a,g:0 ..63 ; char1,char2:'a'..'z'.

Any data - constants, variables, function values ​​- are characterized in Pascal by a data type.

Let's define the concept data type. As is already known, all program objects (variables, constants, etc.) must be described.

Descriptions inform the translator, firstly, about the existence of the variables and other objects used, and secondly, they indicate the properties of these objects. For example, a description of a variable whose value is a number indicates the properties of numbers. Formally, numbers can be integer and real (fractional). In Pascal, as in other programming languages, numbers are divided into two types: whole(reserved word integer) and real(reserved word real).

The separation of integers into a separate type is explained by the fact that in a computer, integers and real numbers are represented differently: an integer can be represented absolutely accurately, but a real number can inevitably be represented with some finite error, which is determined by the properties of the translator.

For example, let the variable x be of type real and its value equal to one: x=1 . The corresponding value in computer memory can be 0.999999999, 1.000000001, or 1.000000000. But if the variable x is declared as a variable of integer type, then the unit in the computer will be represented absolutely precisely and the variable x will not be able to take real (fractional) values ​​- after all, it was described as a variable of the integer type.

So the data type defines:

  • internal representation of data in computer memory;
  • the set of values ​​that quantities of this type can take;
  • operations that can be performed on values ​​of this type.

Introduction of data types is one of the basic concepts of the Pascal language, which is that when performing an operation of assigning a variable to the value of an expression, the variable and the expression must be of the same type. This check is performed by the compiler, which greatly simplifies the search for errors and leads to increased program reliability.

The many data types of the Turbo Pascal language can be divided into two groups:

  • standard (predefined) types ;
  • user-defined types (user-defined types) .

Standard Turbo Pascal types include:

  • integer type – integer;
  • real type – real;
  • character type – char;
  • boolean type – boolean;
  • string type – string ;
  • pointer type – pointer;
  • text type – text .

Custom data types are various combinations of standard types.

Custom types include:

  • enumerated type;
  • interval type;
  • pointer type;
  • structured types;
  • procedural type.

Comment. Another classification of data types is possible, according to which types are divided into simple and complex.

Simple types include: integer type, real type, character type, logical type, enumerated type and interval type.

A complex type is various combinations of simple types (arrays, records, sets, files, etc.)

Standard types

The standard data type is defined by the Pascal language itself. When using standard types in a program, it is enough to indicate the subsections of the required types (const, var) and then describe the constants and variables used in the program. There is no need to use the Type subsection.

For example, if the program uses only variables:

i,j – integer (integers);

x,y - real (real);

t,s - char (character);

a,b – boolean (logical),

then only a subsection of variables is needed - Var. Therefore, in the descriptive part of the program, variable declarations are written as follows:

Integer types

Data of this type can only accept integer values. In a computer, values ​​of an integer type are represented absolutely precisely. If the variable is negative, then it must be preceded by a “–” sign; if the variable is positive, then the “+” sign can be omitted. This type is necessary in the case when some quantity cannot be represented approximately as a real number. For example, the number of people, animals, etc.

Examples of writing integer values: 17, 0, 44789, -4, -127.

The range of variation of data of an integer type is determined by five standard types of integers and is presented in the table:

Type Range Size in bytes
Shortint -128...+128 1
Integer -32768...32767 2
Longint -2147483648...2147483647 4
Byte 0...255 1
Word 0...65535 2

The last two types represent only positive numbers, and the first three represent both positive and negative numbers.

In the text of the program or when entering data of an integer type, the values ​​are written without decimal point . Actual variable values must not exceed permissible values the type (Shortint, Integer, Longint, Byte, Word) that was used to describe the variable. Possible excesses during calculations are not controlled in any way, which will lead to incorrect operation of the program.

An example of using an integer variable

Var a:integer; b:word; c:byte; Begin a:=300; (a is set to 300) b:=300; (b set to 300) c:=200; (c is set to 200) a:=b+c; (a is set to 500) c:=b; (Error! Variable c can only take values ​​of 255. Here variable c is set to 500, which will cause the result to overflow.) End.

Real types

Values ​​of real types are represented approximately in a computer. The range of variation of real type data is determined by five standard types: real (Real), single precision (Single), double precision (Double), extended precision (Extended), complex (Comp) and is presented in the table:

Type Range Number of significant figures Size in bytes
Real 2.9E-39...1.7E+38 11-12 6
Single 1.5E-45...3.4E+38 >7-8 4
Double 5E-324...1.7E+308 15-16 8
Extended 3.4E-4951...1.1E+4932 19-20 10
Comp -2E+63+1...+2E+63-1 19-20 8

Real numbers can be represented in two formats: fixed point and floating point.

The format for writing a fixed-point number is the same as the usual mathematical notation for a decimal number with fractional part. The fractional part is separated from the whole part using a dot, for example

34.5, -4.0, 77.001, 100.56

The floating point notation format is used when writing very large or very small numbers. In this format, the number before the "E" is multiplied by the number 10 to the power after the "E".

1E-4 1*10-4
3.4574E+3 3.4574*10+3
4.51E+1 4.51*10+1

Examples of floating point numbers:

Number Recording in Pascal
0,0001 1E-4
3457,4 34574E-1
45,1 451E-1
40000 4E+4
124 0.124E+3
124 1.24E+2
124 12.4E+1
124 1240E-1
124 12400E-2

In the table from 5 to 9, the row shows the recording of the same number 124. By changing the position of the decimal point in the mantissa (the point “floats”, hence the name “recording a floating point number”) and at the same time changing the order value, you can select the most suitable recording numbers.

An example of describing variables of real type.

Character type

Character values ​​are characters that can be typed on a computer keyboard. This allows you to present text in the program and perform various operations on it: insert, delete individual letters and words, format, etc.

A character type is designated by the reserved word Char and is designed to store a single character. Character data takes up one byte in memory.

Symbolic variable declaration format:

<имя переменной>: Char;

When defining the value of a character variable, the character is written in apostrophes. In addition, you can specify the required character by directly specifying its numeric ASCII code value. In this case, you must precede the number indicating the ASCII code of the required character with a # sign.

An example of using character type variables:

Var c:char; (c is a character type variable) Begin c:=’A’; (variable c is assigned the character 'A') c:=#65; (variable c is also assigned the character A. Its ASCII code is 65) c:=’5’; (variable c is assigned the symbol 5, End. Here 5 is no longer a number)

Boolean type

The logical data type is called Boolean after the English mathematician George Boole, the creator of the field of mathematics - mathematical logic.

Format for declaring a Boolean type variable:

<имя переменной>: boolean;

Data of this type can take only two values:

  • True - true;
  • False is a lie.

Logical data is widely used in checking the validity of certain conditions and in comparing quantities. The result may be true or false.

To compare data, the following relational operations are provided:

An example of using relational operations:

relation 5>3, result true;

relation 5=3, result false.

An example of using Boolean type variables.

Var a,b:boolean; (a,b are variables of logical type) Begin a:=True; (variable a is assigned the value “true”) b:=false; (variable b is set to false) End.

Constants

Integers, real numbers, characters, character strings, and logical constants can be used as constants.

A constant must be declared in its descriptive part using the reserved word const.

Constant Declaration Format

Const<имя константы>= <значение>;

If a program uses several constants, only one is allowed. keyword Const , the description of each constant ends with a semicolon. A constant block ends with the declaration of another section or the declaration of a block of executable statements.

Const (constant section declaration) year=2003; (constant of integer type, because there is no decimal point in the record) time=14.05; (real type constant) N=24; (constant of integer type, because there is no decimal point in the notation) P=3.14; (real type constant) A=true; (boolean constant) str1=’7’; (character type constant) str2=’A’; (character type constant) str3=’Turbo’; (string type constant) Var (variable section declaration) X,y:integer; (integer type variables)

Custom types

Of the set of user types, we will consider only

  • enumerated type;
  • interval type.

We will need these two types when studying arrays.

Enum type

An enumerated data type describes new data types whose values ​​are defined by the programmer. An enumerated type is specified by an enumeration of the values ​​it can receive. Each value is named by some identifier and is located in a list surrounded by parentheses. An enumerated type is a user-defined data type, so its type declaration begins with the reserved word TYPE.

Enum type format:

<имя типа>= (constant1, constant2,..., constantN);

Where
constant1 , constant2 ,..., constantN – an ordered set of identifier values ​​treated as constants.

An example of an enumerated type description:

Type ball=(one, two, three, four, five); var t:ball;

Here ball is the name of the enumerated type; one, two, three, four, five – constants; t is a variable that can take any constant value.

In an enumerated type, a constant is an identifier, so it is not quoted and cannot be a number. Thus, in an enumerated type, a constant is a special kind of constant that cannot be:

  • constants of numeric type: 1, 2, 3, 4, etc.;
  • constants of character type: "a", "s", "1", "3", etc.;
  • constants of string type: "first", "second", etc.

In addition, values ​​of this type do not apply arithmetic operations and standard input and output procedures Read, Write.

An example of using enumerated variables:

Type days = (Monday, Tuesday, Wednesday, Thursday, Friday, Saturday, Sunday); Var day: days; begin if day = Sunday then writeln(‘Today is Sunday!’); End.

The elements included in the definition of an enumerated type are considered to be ordered in the order in which they are enumerated. Numbering starts from zero. Therefore, in the example given, the days of the week have the following serial numbers

For software definition The Ord() function is used to determine the ordinal number.

In our example, the sequence numbers are equal:

Ord(Monday) = 0;

Ord(Saturday) = 5;

Ord(Sunday) = 6.

Interval type

If a variable does not accept all values ​​of its type, but only values ​​contained in a certain range, then this data type is called an interval type. The interval type is often called the limited type and the range type. An interval type is defined by the boundaries of its values:

<минимальное значение>..<максимальное значение>

  • two ".." characters are treated as one character, so spaces between them are not allowed;
  • the left border of the range should not exceed its right border.

The interval type is a user-defined data type, so the declaration of this type begins with function word TYPE.

An example of an interval type description:

Type digit = 1..10; month = 1..31; lat = 'A'..'Z';

You are in the Pascal programming materials section. Before we start programming, we need to clarify some concepts that we will need in the beginning. After all, you can’t just program like that. We cannot write the program in words - the computer does not understand anything other than zeros and ones. For this purpose, special symbolism was created in Pascal - the Pascal language, a set reserved words, which cannot be used anywhere else in your programs except for their intended purpose. Let's list the basic concepts that we will need at the beginning:

✎ 1) program – in English “program”, written at the very beginning of the code, followed by the name of the program in Latin and a semicolon. For example: program Summa; − a program called Summa. But this part of the code, called the program header, does not need to be written - it is present only for clarity and shows what problem it solves this program. Here we used the word “code” - this is the name of the text entry of the program.

✎ 2) integer – in English means “integer” (or simply “integer”) and in Pascal is used to denote 32-bit (8 bytes) signed integers from the range [-2147483648, 2147483647] . We will look into what these large numbers mean later.

✎ 3) real – from English “real”, “real”, “real”, “real”. In the Pascal language, this term denotes real numbers in the range [-1.8∙10 308, 1.8∙10 308]. These are very large numbers, but 15 - 16 significant digits are displayed. By the way, the integer and real data types in the PascalABC.Net programming environment are always automatically highlighted in blue.

✎ 4) const – analogue of English. "constant", meaning "constant", "constant". In Pascal, this is a quantity that cannot change. It is written like this:


This entry must be taken as it is written: the number N is 12, S is 5, “pi” is 3.14 (as in mathematics, only a dot is used instead of a comma in Pascal). IN last line we used double slash (two forward slashes), followed by text - this is how comments are written in Pascal, and the program does not perceive them. Everything that begins with a double slash and until the end of the line is a comment, which is written to explain the program and is always highlighted in a different color (in PascalABC.Net it is green, in Turbo Pascal This type of comment is not used). There is another type of comment - this (text enclosed in curly brackets, just like here, also highlighted in green). This type of comment can be valid for several lines in a row - from the beginning of the bracket to its closing, and the compiler does not perceive everything that is in the middle of such a construction as code and simply skips it.

In reality the recording format const a little more complicated. According to the rules, we had to write:

1 2 3 4 const N: type integer;

Description:

")" onmouseout="toolTip()">integer
= 12 ; //number N – integer type S: type integer;

Description:
Represents a 32-bit signed integer.

Value range: -2 147 483 648 .. 2 147 483 647")" onmouseout="toolTip()">integer
= 5 ; //number S – integer type pi: type real;

Description:
Represents a double precision floating point number.

Size: 8 bytes
Number of significant figures: 15 - 16
Value range: -1.8∙10 308 .. 1.8∙10 308
")" onmouseout="toolTip()">real
= 3.14 ; //number "pi" - real

After declaring each value, its type is indicated, and then a value is assigned. But the previous entry is also correct, since the Pascal compiler is configured so that it automatically determines the type of a constant. But this cannot be said about the next type of numbers - variables.

✎ 5) var – comes from English. “variable” (“variable” or “changeable”), which in Pascal means a value that can change its value during the program. It is written like this:


As can be seen from the entry, there is no “=” sign here - variables of the same type are recalculated (separated by commas) and only the type is indicated after the colon. The variables N, m (integer) and Q, r, t (real) in the program can change values ​​within the limits of integer and real, respectively. One more note: the description of variables always comes after the description of constants (constants) - the const construction comes first, and then var.

✎ 6) begin – translated from English means “to begin” and Pascal means the beginning of the main program in which commands (operators) are written. After the word begin There is no semicolon.

✎ 7) end – in English. "end" and Pascal language means the same (end of program). After the last word end there is always a period. We have emphasized the word “last” because the use of the construction begin–end perhaps in one more case: these are the so-called operator brackets, which are used to combine several operations under one operator. But more on that later. So the main program will look like this:

1 2 3 4 5 6 begin < оператор 1 > ; < оператор 2 > ; . . . . . . . < оператор N > ; end.

Here, the operators in the body of the program are different commands to the compiler.

✎ 8) write – in English means “to write”. This operator displays the text placed in it, which is why it is called the output operator. The text placed inside it is highlighted in blue and written like this:

Write( "this text is displayed on the screen");

A message inside parentheses and quotes will be shown in the console window (you can't just put it in parentheses without quotes). After executing this statement we will see on the screen:

this text is displayed on the screen

In this form, the write operator is used in the case when you need to show a hint, explanation, comment, etc. And if you also need to display a numerical value, say, S = 50 sq. m, then the format is used:

Write(, S);

As a result, we get the result on the screen:

The area is equal to: S = 50

And if you need to display units of measurement, you need to insert the text in quotes again after S:

Write( "The area is equal to: S = ", S, " sq.m" );

After executing the last output statement, we get the following output on the screen:

The size of the area is: S = 50 sq.m

✎ 9) writeln – the same as write, but after execution the cursor will be moved to the next line.

✎ 10) read – translated from English means “to read”, so read is called the read or data input operator. It is written as read(N), which means that the value N must be entered, where N is any number, or text, or other type of variable. For example, if we need to enter the age of a person who is 32 years old, we can write it like this:


In the first line of this code, the program displays the question “ What is your age?" and moves the cursor to the next line (ending ln); in the second line we print “Year =” (space at the beginning); Next we see the readln(Year) operator, which means it is necessary to enter the age Year (number 32); finally, we display the messages “My age”, “32” and “years. " one by one. You need to watch the spaces carefully. As a result of executing this code, we will receive the message:

What is your age?
Year = 32
My age is 32 years old

✎ 11) readln – the same as read, only translated into new line. Indeed, in the above example, after introducing the number Year, we only write in the next line: “ My age is 32 years old».

That's all for now. On the next page we will write the first program, and in Pascal programming this will be our