Programming language
Pascal programming language – the Pascal is one of the more recently
developed and more promising programming language. It was devised by
Nicklaus wirth between 1968 to 1971.
Pascal language is considered to have a great deal of potential for computer
user because it facilitates the use of structures programming techniques.
Its designed to standardized programming and make debugging easier.
Pascal was recently adopted as primary language for many microcomputers.
Pascal programming language was the most important programming
language of 1980
Pascal programming language advantages
Transparency - a program that can easily read and
understand. Given a well written Pascal program, it
can easily be seen what is intended effect is.
Efficiency – this concern of the sized and speed at
which they run the computer.
Security – after writing a program in Pascal, the
computer ,and in particular compiler. Pascal is able to
spot mistakes. Because Pascal programs are
transparent.
Pascal data types
The basic data types in pascal includes
Integer
Real
Char
Boolean
Word
Longint
Byte
shortint
Pascal - Arrays
Pascal programming language provides a data structure called the array,
which can store a fixed-size sequential collection of elements of the same
type.
Instead of declaring individual variables, such as number1, number2, ..., and
number100, you declare one array variable such as numbers and use
numbers[1], numbers[2], and ..., numbers[100] to represent individual
variables. A specific element in an array is accessed by an index.
All arrays consist of contiguous memory locations. The lowest address
corresponds to the first element and the highest address to the last element.
Types of arrays
Declaring Arrays
To declare an array in Pascal, a programmer may either declare the type and
then create variables of that array or directly declare the array variable.
array-identifier − indicates the name of the array type.
index-type − specifies the subscript of the array; it can be any scalar data type
except real
element-type − specifies the types of values that are going to be stored
Types of Array Subscript
In Pascal, an array subscript could be of any scalar type like, integer, Boolean,
enumerated or sub range, except real. Array subscripts could have negative
values too.
Initializing Arrays
In Pascal, arrays are initialized through assignment, either by specifying a
particular subscript or using a for-do loop.
Accessing Array Elements
An element is accessed by indexing the array name. This is done by placing the
index of the element within square brackets after the name of the array.
Concept & Description
1.Multi-dimensional arrays
Pascal supports multidimensional arrays. The simplest form of the
multidimensional array is the two-dimensional array.
2.Dynamic array
In this type of arrays, the initial length is zero. The actual length of
the array must be set with the standard SetLength function.
3.Packed array
These arrays are bit-packed, i.e., each character or truth values are
stored in consecutive bytes instead of using one storage unit,
usually a word (4 bytes or more).
4. Passing arrays to subprograms
You can pass to a subprogram a pointer to an array by specifying
the array's name without an index.