Читайте также: |
|
A high level language is a language in which each instruction or statement correspond to several machine code instructions. It is contrasted with a low level language in which each instruction has a single corresponding machine code equivalent. High level languages allow users to write in a notation with which they are familiar, e.g., FORTRAN in mathematical notation, COBOL in English. So, high level languages are oriented to the problem, while low level languages are oriented to the machine code of a computer.
FORTRAN. FORTRAN is an acronym for FORmula TRANslation. It is a problem oriented high level programming language for scientific and mathematical use, in which the source program is written using a combination of algebraic formulae and English statements of a standard but readable form. FORTRAN was the first high level programming language. It was developed in 1954, and was designed to easily express mathematical formulas for computer processing. It is still the most widely used programming language. There were several versions of FORTRAN. The most popular and used was FORTRAN-4.
A FORTRAN program consists of data items, executable statements and non-executable statements. The program is structured in segments which consist of a master segment and optional function segments and subroutines.
Data items in FORTRAN are either variables or constants, and are assigned alphanumeric names by the programmer. Group of similar items of data can be processed as arrays, or tables of data, in which case the individual items are defined by one or more subscripts.
Data items in FORTRAN may take the following forms:
Integer is a whole number value falling within a range determined by the capacity of the computer being used.
Real is a number expressed in floating-point representation accurate to a number of significant digits, the range again depends on the capabilities of the particular machine being used.
Complex is a number in which two real numbers are used to express the real and imaginary parts.
Logical is a quantity which can only take two values, true or false. Text is character information, which is not used for mathematical operations.
The actual operations of the program are expressed by means of ‘executable statements’. These can take two forms: ‘assignment statement’ and ‘control statements’. An assigned statement takes the form Variable = Expression. The expression may be either arithmetic or logical. An arithmetic expression can include variables, elements, form arrays, constants and a variety of standard functions which are combined by arithmetic operations, e.g., +, -, * (multiplication), / (division), ** (exponentiation). A logical expression is similar but include the operations AND, NOT, OR, etc, and the logical operators.
An example of an arithmetic assignment statement would be:
ROOT = (-B +SQRT (B**2 - 4*A*C0))/(2*A),
where the word ROOT and the letters A, B, C represent variables and SQRT – the function provided for calculating square roots. The compiler recognizes these symbols and translates them into appropriate machine code. An example of a logical assignment statement would be: BOOL-A.OR.B. In this expression the variable BOOL would be given the value true or false according to the truth values of variables A and B, and the truth table defined by the Boolean operator OR.
Each statement can be preceded by a numerical label, permitting reference to the statement by means of control statements. Control statements enable the program to branch to other statements. Branches themselves may also be constructed which are conditional on results of arithmetic or logical operations.
As was said above, a FORTRAN program consists of one or more segments, of which there is one and only one master segment, and optionally function and subroutine segments. A function segment is used where the same form of function is required several times in a program. The statements describing the operation required to calculate the result of using the function are named and written once, and whenever the function is required in the program it is only necessary to give the function name and a list of parameters to replace the ’dummy’ variables used in the function segment.
4. Answer the following questions:
1. What is FORTRAN?
2. What are low lever languages oriented to?
3. What are high level languages oriented to?
4. When was FORTRAN developed?
5. What does a FORTRAN program consist of?
6. Who assigns alphanumeric names to data items?
7. Which forms may data items in FORTRAN take?
8. By means of what are the actual operations expressed in FORTRAN?
9. How is a program in FORTRAN structured?
10. What do segments in a FORTRAN program consist of?
Дата добавления: 2015-07-18; просмотров: 169 | Нарушение авторских прав
<== предыдущая страница | | | следующая страница ==> |
PROGRAMMING LANGUAGES | | | The elements of programming |