Добавил:
Upload Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз: Предмет: Файл:
Тексты по английскому языку.doc
Скачиваний:
41
Добавлен:
01.04.2015
Размер:
302.08 Кб
Скачать

Text 22 high level programming languages basic & pascal

BASIC was developed in 1965 and stands for Beginners All-purpose Symbolic Instruction Code. It is a programming language designed for solving mathematical and business problems. BASIC was originally developed as an interactive programming language for time-sharing on large mainframes. It is widely used on all sizes of computers and has become extremely popular on microcomputers.

There are many different versions of BASIC available with limited versions running on small hand-held computers. BASIC is available in both compiler and interpreter form, the latter form being more popular and easier to use, especially for the first-time programmer. In interpreter form the language is conversational and can be used as a desk calculator. In addition, it is easy to debug a program, since each line of code can be tested one at a time.

BASIC is considered to be one of the easiest programming languages to learn. For simple problems BASIC programs can be written ‘on the fly’, at the terminal. However, complex problems require programming technique, as in any conventional programming language. Since BASIC does not require a structured programming approach, like PASCAL, and since there is no inherent documentation in the language, as in COBOL, BASIC programs can be difficult to decipher later if the program was not coherently designed.

There is no one BASIC language, but something like 90 different versions or dialects; however, all have certain common features that make it easy to use any version once the fundamentals are mastered. Since BASIC is job and human oriented, it cannot be understood by the computer as written, but must go through the intermediate step of a compiler or interpreter. As far as the programmer is concerned, it makes very little difference whether a compiler or interpreter is used.

PASCAL. PASCAL is a general-purpose high level programming language. It is named after the famous French mathematician, Blaise Pascal, who in 1642 designed and built the first mechanical calculator, the “Pascaline”. PASCAL is noted for its simplicity and structured programming design. It is available as both a compiler and an interpreter.

PASCAL was proposed and defined in 1971, and gained popularity in universities and colleges in Europe and the United States. It was later revised and appeared as standard PASCAL in 1975. Its principal features are on teaching programming and on the efficient implementation of the language.

PASCAL may be considered a successor to ALGOL-60, from which it inherits syntactic appearances. The novelties of PASCAL lie mainly in extensive data structuring facilities such as record, set and file structures. It also affords more sophisticated control structures suitable to structured programming.

An algorithm of a computer program consists of two essential parts: a description of actions which are to be performed, and a description of the data, which are manipulated by these actions. Actions are described by statements, and data are described by declarations and definitions.

The program is divided into a heading and a body, called a block. The heading gives the program a name and lists its parameters. These are file variables and represent the arguments and results of the computation. The file output is a compulsory parameter. The block consists of six sections. They are: label declaration part, constant definition part, type definition part, variable declaration part, procedure and function declaration part, and statement part.

The first section lists all labels defined in this block. The second section introduces identifiers for constants. The third section contains type declarations, and the fourth – variable definitions. The fifth section defines procedures and functions. And the last, the sixth, gives the statements which specify the actions to be taken.

The statements used in PASCAL may be: EMPTY statement, GOTO statement, structured statement, compound statement, conditional statement, repetitive statement, WITH statement, etc.

Program structure. In Standard Pascal, programs adhere to a rigid format. You do not have to have all five declaration sections — label, const, type, var, and procedures and functions — in every program. But in standard Pascal, if they do appear, they must be in that order and each section can appear only once. The declaration section is followed by any procedures and functions you might have, then finally the main body of the program, consisting of some number of statements.

Turbo Pascal gives you tremendous flexibility in your program structure. All it requires is that your program statement (if you have one) be first and that your main program body be last. Between those two, you can have as many declaration sections as you want, in any order you want, with procedures and functions freely mixed in. But identifiers must be defined before they are used, or else a compile-time error will occur.

Procedure and function structure. As mentioned earlier, procedures and functions — known collectively as subprograms — appear anywhere before the main body of the program.

Functions look just like procedures except that a function declaration starts with a function header and ends with a data type for the return value of the function.

As you can see, there are only two differences between this and regular program structure: Procedures or functions start with a procedure or function header instead of a program header, and they end with a semicolon instead of a period. A procedure or function can have its own constants, data types, and variables, and even its own procedures and functions. What's more, all these items can only be used with the procedure or function in which they are declared.