/ / What are the types of data in Pascal?

What are the types of data in Pascal?

When programming in the language of Pascal (Pascal)you must select the Pascal program data types. It is important for the programmer to understand that to run his program in RAM, a place is allocated for storing not only the commands, but also the data with which these commands work.

data types in pascal
All types of data in Pascal fall into two groups: simple and structured. For each data type, a number of bytes are allocated. Simple types include: integer types (byte, integer, etc.), real types (real, single, etc.), logical type (boolean), character type (char), enumerated and interval type. All of them, with the exception of real types, are ordinal types and are characterized by having a limited ordered set of values. For example, a variable of type byte can take values ​​in the range from 0 to 255, inclusive. These types of data in Pascal allow you to use the Pred function (calculates the previous value) and Succ (calculates the subsequent value), Low (calculate the smallest value of the type) and High (calculates the highest value of the type), Ord (calculates the current variable's sequence number).

A simple type variable as a valuehas only one given, i.e. a single integer, a fractional number, or one character. Variables that have simple data types in Pascal must be described in the Var section (short for Variables).

pascal data types
Variable in the Pascal program is consideredfully specified if it has a name (identifier), type, and initial value. The variable name is used when accessing it by means of an operator. The data type defines the range of the representation (what values ​​the variable can take), the operations in which it can participate, the amount of memory that is required to store the variable in the RAM. Therefore, when solving a problem, one should tend to reduce the number of variables and rational selection of their types.

Structured types areordered set of variables of simple types. These include: arrays, sets of, strings, files, and records. Structured data types in Pascal are described in the type section.

The array is the most common ofstructured types, is used when you want to store and process an ordered set of variables of the same type (of any simple type). Arrays are one-dimensional, two-dimensional, multidimensional. An example of a one-dimensional array can be a list of students in the class journal, sorted alphabetically, where each student has a unique serial number. An example of a two-dimensional array is the location of places in the auditorium of the cinema (each location is determined by two dimensions - the number of the row and the number of the place).

datatypes in pascal

Elements of a set, unlike an arrayare unordered, and the number of elements is limited to 255. A string is an ordered set of characters, and this is very similar to an array, but only characters can be line items.

The file is the same array, but the number of elements in it can change during the program execution. A record is a collection of different types of data.

Having learned to apply data types in Pascal, you can implement fairly complex and interesting tasks.

Read more: