Студопедия
Случайная страница | ТОМ-1 | ТОМ-2 | ТОМ-3
АвтомобилиАстрономияБиологияГеографияДом и садДругие языкиДругоеИнформатика
ИсторияКультураЛитератураЛогикаМатематикаМедицинаМеталлургияМеханика
ОбразованиеОхрана трудаПедагогикаПолитикаПравоПсихологияРелигияРиторика
СоциологияСпортСтроительствоТехнологияТуризмФизикаФилософияФинансы
ХимияЧерчениеЭкологияЭкономикаЭлектроника

The elements of programming

Читайте также:
  1. Compounds and Elements
  2. Elements
  3. HIGH LEVEL PROGRAMMING LANGUAGES FORTRAN
  4. PROGRAMMING LANGUAGES
  5. RPG II Programming language
  6. Text 1. COMPUTER PROGRAMMING

Most programs are designed to solve a problem. They solve problems by manipulating information or data. As a programmer you do the following:

• get the information into the program — input.

• have a place to keep it — data.

• give the right instructions to manipulate the data— operations.

• be able to get the data back out of the program to the user (you, usually) — output.

You can organize your instructions so that

• some are executed only when a specific condition (or set of conditions) is True — conditional execution.

• others are repeated a number of times — loops.

• others are broken off into chunks that can be executed at different locations in your program — subroutines.

These are the seven basic elements of programming: input, data, operations, output, conditional execution, loops, and subroutines. This list is not comprehensive, but it does describe those elements that programs (and programming languages) usually have in common. Many programming languages, including Pascal, have additional features. And when you want to learn a new language quickly, you can find out how that language implements these seven elements, and then build from there. Here's a brief description of each element:

Input. This means reading values in from the keyboard, from a disk, or from an I/O port.

Data. These are constants, variables, and structures, that contain numbers (integer and real), text (characters and strings), or addresses (of variables and structures).

Operations. These assign one value to.another, combine values (add, divide, and so forth), and compare values (equal, not equal, and so on).

Output. This means writing information to the screen, to a disk, or to an I/O port.

Conditional execution. This refers to executing a set of instructions if a specified condition is True (and skipping them or executing a different set if it is False) or if a data item has a specified value or range of values.

Loops. These execute a set of instructions some fixed number of times, while some condition is True or until some condition is True.

Subroutines. These are separately named sets of instructions that can be executed anywhere in the program just by referencing the name.

UNIT XVIII

1. Read and translate the text:

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.

A compiler generally used in a large computer converts the source program written in BASIC to an object program or file in machine language which is then stored in memory. In the compiler each BASIC phrase or statement is converted to one or more machine instructions. An interpreter is similar in result, but conversion is usually done while the program is running, one statement at a time. The difference between the two, which is important to the microprocessor user, is that the interpreter must be present in memory while the program is being run while the compiler can be removed once it has done its job.

One would think then that a microcomputer would most often use a compiler, but this is not the case. Since interpreter programs can be run line-by-line, they can be debugged simply rather that being recompiled for each correction, and they are more popular in small computers. In certain versions the interpreter is stored in ROM, which is less expensive than RAM, and does not need to be loaded from some external source such as a cassette.

The typical example of the algorithm in BASIC can be written as follows:

1. REM THIS PROGRAM SEARCHES A LIST AND PRINTS THE ADDRESS

10 DATA 74, 83, 66, 67, 87, 65, 84, 80, 76, 70

20 LET N =10

30 LET X =65

40 LET J =N

50 IF J = 0 GOTO 100

60 READ K

70 JF K = GOTO 100

80 LET J = J –1

90 GOTO 50

100 PRINT J

110 END

BASIC features the fact that every line is a statement and every statement must be preceded by a line number followed by space. Any statement on a line beginning with REM is ignored by the interpreter or compiler. However, these REMarks may be extremely valuable in explaining the purpose and method of the program. Some BASIC variations use the apostrophe (‘) as an abbreviation for REM.

BASIC has various expressions (constants and variables combined by arithmetic and algebraic operators), line numbers, spaces, remarks, data, and statements. BASIC statements may be: LET statement which is the simplest kind of an arithmetic assignment statement, READ statement, GOTO statement, IF THEN statement, etc. In the case of the IF statement we are interested in whether the relation between two expressions following the IF is TRUE or FALSE. In other words we are interested in the Boolean value of the expression following IF.

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.

2. Find in (b) the Russian equivalents to the following word combinations in (a):

a) 1. the Boolean value; 2. repetitive statement; 3. identifiers for constants; 4. type declaration; 5. step-by-step; 6. line-by-line; 7. hand-held computers; 8. to debug a program; 9. basic features; 10. this is not the case; 11. conditional statement; 12. general-purpose languages;

b) 1. основные особенности; 2. идентификаторы постоянных величин; 3. построчный; 4. отладить программу; 5. описание типа; 6. портативные компьютеры; 7. это не так; 9. поэтапный; 10. условный оператор; 11. универсальные языки; 12. Булево значение; оператор повторений.

3. Read and translate the verbs meaning repetition:

Retype; recompile; recycle; re-emphasize; relocate; reread; rewrite; reoccur; rearrange; reappear; replace; restart; rewind; review; return.

4. Read and translate the words meaning negotiation:

Unusual, unused; unspecified; unlimited; unsatisfactory; infrequently; unseparated; independent; indirect; indistinguishable; impossible; disadvantage; disadvantage; disjunction; decode; regardless; useless.

5. Answer the following questions:

1. What is BASIC? 2. What kinds of problems is BASIC designed for? 3. Why is the BASIC language popular on microcomputers? 4. Is it easy to debug a program written in BASIC? 5. What BASIC statements do you know? 6. What is PASCAL? 7. Who is PASCAL named after and why? 8. When did PASCAL appear as standard language? 9. How is a program in PASCAL divided? 10. How many sections does a block consist of? 11. Does PASCAL have the block structure? 12. What statements in PASCAL can you name? 13. What forms do the programs in Turbo Pascal adhere? 14. What declaration sections can appear in standard Pascal and in what order? 15. Where do procedures and functions appear in a program? 16. What are the differences between this and regular program structure?:

6. a) Compare BASIC and PASCAL;

b) Speak on the difference in BASIC and PASCAL structures.

c) Speak about the program structure of Turbo Pascal.

7. Read the following texts and render it. Write a short summary:

C LANGUAGE

Programming language С has been developed in the beginning of the seventieth years as tool means for realization of operational system UNIX on IBM PDP-11,however its popularity has quickly developed frameworks of the concrete IBM,concrete operational system and specific targets of system programming. Somewhat language С – the most universal as except for a set of the means inherent in the modern languages of programming of a high level, in it are included means for programming almost at a level of the assembler (use of indexes, bit-by-bit operations, operations of shift). The big set of operators and operations allows writing compact and effective programs. However such powerful means demand from the programmer of care, accuracy and good knowledge of language with all its advantages and lacks

As base language for С ++ language С as it, first, is flexible, compact has been chosen and has rather low level; second, approaches for programming the majority of system problems; thirdly, works everywhere and on all; and fourthly, it will be coordinated to environment programming UNIX.

One of the initial purposes of creation of language С – to replace development of programs in language of the assembler for most challenges of system programming. By development С ++ paid special attention to not lose the advantages achieved in this area. Distinction between С and С ++ first of all consists in a degree of attention to types and structures. Language С possesses significant expressive force. С ++ has still the big expressive force but to reach increase of expressiveness, the programmer should give more attention to types of objects. Knowing types of objects the compiler can correctly process expressions whereas otherwise the programmer should paint with operation with depressing details. Knowledge of types of objects also allow the compiler to find out mistakes which otherwise would not be shown before testing.

8. Read and translate the text:

History of C++

During the 60s while computers were still on early stage of development many new programming languages appeared. Among them ALGOL 60 was developed as an alternative to FORTRAN but taking from it some concepts of structured programming which would later inspire most procedural languages. ALGOL 68 also influenced directly in the development of data types in C. Nevertheless ALGOL was an unspecific language and its abstraction made it little practical to solve most commercial tasks.

In 1963 the CPL (Combined Programming language) appeared with the idea of being more specific for concrete programming tasks of that time than ALGOL or FORTRAN. Nevertheless the same definition made it a cumbersome language and therefore difficult to learn and to implement.

In 1967 Martin Richards developed the BCPL (Basic Combined Programming Language) that signified simplicity of CPL but kept the most important features the language offered although it continued to be an abstract and somewhat cumbersome language.

In 1970 Ken Thompson immersed in the development of UNIX at Bell Labs, created the В language. It was a port of BCPL for a specific machine and system (DEC PDP-7 and UNIX) and was adapted to his particular taste and necessities. The final result was an even greater simplification of CPL and it was dependent on the system. It had great limitations such as it did not compile to executable code but threaded-code, which generates slower code in execution, and therefore was inadequate for the development of an operating system. It was the reason why since 1971, Denis Ritchie, from the Bell Labs team, began the development of а В compiler which, among other things, was able to generate executable code directly. This "New B", finally called C, introduced in addition some other new concepts to the language for example, data types (char).

In 1973 Denis Ritchie had developed the bases of C. The inclusion of types its handling as well as the improvement of arrays and pointers, along with later demonstrated capacity of portability without becoming a high-level language contributed to the expansion of the С language. It was established in the book "The С Programming Language" by Brian Kernighan and Denis Ritchie known as the White Book. That served as de facto standard until the publication of formal ANSI standard (ANSI X3J11 committee) in 1989.

In 1980 Bjarne Stroustrup from Bell labs began the development of the C++ language, that would receive formally this name at the end of 1983 when its first manual was going to be published. In October 1985 the first commercial release of the language appeared as well as the first edition of the book "The C++ Programming Language" by Bjarne Stroustrup.

During the 80s the C++ language was being refined until it became a language of its own personality. In fact, the ANSI standard for the С language published in 1989 made great contributions to C++ for the structured programming.

From 1990 ANSI committee X3J16 began the development of a specific standard for C++. The period before the publication of the standard in 1998, C++ greatly developed in its use and today it is the most widely used language for developing the professional applications in all platforms.

9. Speak about the history of C++ language.

UNIT XIX

1. Read and learn the new words:

World Wide Web — всемирная паутина

recreation — извлечение

network — сеть

to share — делить

humanities — гуманитарные науки

business transactions — коммерческие операции

to browse — рассматривать, разглядывать

browser — браузер (программа поиска информации)

provider — провайдер (компания, предоставляющая доступ к WWW через местные телефонные сети)

broadcast live — передавать в прямом эфире

site — страница, сайт

to link — соединять

hyperlink — гиперссылка

to compete — соревноваться

2. Read and translate the text:


Дата добавления: 2015-07-18; просмотров: 101 | Нарушение авторских прав


Читайте в этой же книге: Personal Computer (PC) | HARDWARE | Give definitions to the following using the vocabulary | LOOKING AT OPERATING SYSTEM | Organizing Files into Directories | Speak how to organize your files and directories. | TYPES OF SOFTWARE | OPERATING SYSTEMS | WINDOWS 95 | PROGRAMMING LANGUAGES |
<== предыдущая страница | следующая страница ==>
HIGH LEVEL PROGRAMMING LANGUAGES FORTRAN| INTRODUCTION TO THE WWW AND THE INTERNET

mybiblioteka.su - 2015-2024 год. (0.016 сек.)