Pascal - Pascal programming

Pascal is a programming language developed by Niklaus Wirth around 1970. It is a rather simple language of moderate size and complexity, but powerful, compact, reliable, and efficient. Its clarity, simplicity, and structure make it most suitable as the first language to be learned. In fact, one of Wirth’s major design goals was to produce a language that would be suitable for the teaching of programming. It is not a good idea to skip the fundamental concepts that were introduced in the Principles, and begin by learning the language, for, as good as Pascal is, it is unnecessarily restrictive to think in terms of any one programming language.

An example Pascal program

In the Principles you’ve seen a number of simple pay algorithms. Although we don’t want to anticipate on the presentation of the various features of the Pascal programming languages, we’ll show you now the Pascal program corresponding to the Pay algorithm found at the left of Figure of the Principles book. The spreadsheet Pascal program we’ve just seen was mostly based on invocations, which made it extremely simple. This simple pay program is a better example of what Pascal statements look like. We’ll reproduce here in Figure the original pay algorithm.

A simple pay algorithm

A simple pay algorithm

The corresponding Pascal program is given in Figure Try and match the various parts of the flowchart with the various parts of the program. This should not be too difficult as we have been careful to use indentation to show more clearly the various parts of the program (and help you match the IFs with the ELSEs).

The Simple Pay Pascal program

The Simple Pay Pascal program

Running Programs: Compiling, Linking, Executing

As illustrated in the Principles, the complete creation of a program takes a number of steps. In fact, our problem solving method has seven steps, But even the Program Coding and Testing step is itself made of a number of smaller steps or stages. The diagram in Figure shows the sequence of stages (Editing, Compiling, Linking, and Executing), and what is involved at each stage. These stages must be followed in order to get a computer to run a program properly.

Stages of the Program Coding step

Stages of the Program Coding step

Editing: this might be the hard part of the Program Coding step. The algorithm is coded in some programming language, in this case Pascal. Through the use of an editor application program , the program is put into some computer readable form. This form of the program is the source code.

Compiling: this is the process of translating a source program into a lower -level machine language program, the object program. This translation process is performed by another application program, a compiler. There is a different compiler for each programming language and for each machine on which the program is to run. Part of the compiling process involves checking the source code for syntax errors.

Linking: this is the process of connecting a program to other separately compiled programs such as modules from various Libraries. If all the parts that comprise the complete program are available, the result of linking will be an executable program. If some parts are missing, error messages will be produced to explain why the link did not complete properly.

Executing: this is the process of running the executable program on the computer. An executable program can be executed any number of times without additional compiling or linking. Any errors detected during these stages must be corrected, and the stages tried again in the sequence shown. If there are no errors or other changes, then to rerun the program requires only executing the executable program at the last stage.

All rights reserved © 2020 Wisdom IT Services India Pvt. Ltd DMCA.com Protection Status

Pascal programming Topics