Studying the basics of programming, the first thing (or second) future programmers get acquainted with the concept of "one-dimensional array." Pascal, like other languages, allows you to work with such a data structure. Sooner or later, the need arises for a structured storage of any quantities. Most often, elements from this set belong to the same type. For example, a study group list can consist of 25 elements, each of which is a string type variable that stores the student's last name and first name.
This is what makes it possible to implement a one-dimensional array in Pascal, which is an ordered collection of elements of the same type. Any element of such a sequence can be accessed using the same identifier and one index - a serial number. Therefore, these arrays are called one-dimensional.
The numbering of the elements of the sequence, as a rule, begins with a unit, i.e. the first element has serial number 1, which is quite logical. However, if necessary, the range of indices can be absolutely arbitrary, the main requirement is that the indices are either integers or characters (any ordinal type).
Consider typical actions with a one-dimensional array:
1) Description of the array, here n is the number of elements in the sequence, mas is the type denoting a one-dimensional array of 5 integers, A is a variable of type mas, i.e. variable of type one-dimensional array of 5 integers
2) Entering sequence elements from the keyboard
3) Displaying sequence elements on the screen
4) Filling a sequence using a random number generator
5) Transformation (modification) of each element of the array, i.e. changing its value (an example of reducing each element of a one-dimensional array by 6 is given)
6) Determining the sum of the elements of a sequence, here the variable S is the sum of the elements
7) Determining the number of elements in the array that satisfy a certain condition (an example is given of determining the number of elements greater than 4), here k is the number of such elements
8) Determination of the extremum (maximum or minimum element of the array), here min is the minimum value among the elements of the array, k is the serial number (index) of the smallest element of the array
As you know, for all the variables that are described in the Var section of a program in the Pascal programming language, a certain number of bytes in RAM is allocated when the program starts. This is determined by the type of variable, for example, a character occupies one byte, an integer type two bytes, a real type four bytes. Therefore, in the case when the dimension of the array is small, the program does not require a large amount of RAM. Otherwise, the programmer will have to look for other ways to place the elements of the array, for example, in a file or in dynamic memory, using pointers.