Добавил:
Upload Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз: Предмет: Файл:
UP_Programmin_Language3.doc
Скачиваний:
99
Добавлен:
16.03.2015
Размер:
2.48 Mб
Скачать

Computer programming

Part I

Computers are controlled by sets of instructions called programs. Programs are written by a person called a programmer using special languages called programming languages. Programs can be written in a variety of computer languages. The language chosen will depend on a number of factors including what system the program will run on, what the function of the program is, and the knowledge of the programmer.

Programming is the process of preparing a set of coded instructions which enables the computer to solve specific problems or to perform specific functions. The essence of computer programming is the encoding of the program for the computer by means of algorithms. The thing is that any problem is expressed in mathematical terms; it contains formulae, equations and calculations. Any problem must be specially processed for the computer to understand it, that is – coded or programmed.

The phase in which the system's computer programs are written is called the development phase. The programs are lists of instructions that will be followed by the control unit of the central processing unit (CPU). The instructions of the program must be complete and in the appropriate sequence, or else the wrong answers will result. To guard against these errors in logic and to document the program's logical approach, logic plans should be developed.

There are two common techniques for planning the logic of a program. The first technique is flowcharting.

A flowchart is a plan in the form of a graphic or pictorial representation that uses predefined symbols to illustrate the program logic. It is, therefore, a "picture" of the logical steps to be performed by the computer. Each of the predefined symbol shapes stands for a general operation. The symbol shape communicates the nature of the general operation, and the specifics are written within the symbol. Flowcharts have arrowheads to indicate the direction of program flow and special symbols to indicate different functions in the program.

The second technique for planning program logic is called pseudocode. Pseudocode is an imitation of actual program instructions. It allows a program-like structure without the burden of programming rules to follow. Pseudocode is less time-consuming for the professional programmer than is flowcharting. It also emphasizes a top-down approach to program structure.

Pseudocode has three basic structures: sequence, decision, and looping logic. With these three structures, any required logic can be expressed.

Part II

Types of error

It is very difficult to write a program without any faults. The errors, or bugs as they are commonly known, can be caused by a number of factors, and programs usually have to be debugged, i.e. tested and altered to eliminate all the errors, before they are used.

System errors affect the computer or its peripherals. For example, you might have written a program which needs access to a printer. If there is no printer present when you run the program the computer will produce a system error message. Sometimes a system error makes the computer stop working altogether and you will have to restart the computer. A sensible way of avoiding system errors is to write code to check that peripherals are present before any data is sent to it. Then the computer would warn you by a simple message on the screen, like 'printer is not ready or available'.

Syntax errors are mistakes in the programming language (like typing PRNIT instead of PRINT). Syntax errors cause the program to fail. Some translator programs won't accept any line that has syntax errors. Some only report a syntax error when they run the program. Some languages also contain special commands such as debug, which will report structural errors in a program. The programming manual for the particular language you're using will give details of what each error message means.

Logic errors are much more difficult to detect than syntax errors. This is because a program containing logic errors will run, but it won't work properly, for example, you might write a program to clear the screen and then print 'hello'. Here is a code for this:

10// Message 30 CLS

20 PRINT 'Hello' 40 END.

The code has a logic error in it, but the syntax is right so it will run. Logic errors sometimes occur at branches and loops in a program. You can get rid of logic errors from simple programs by ‘hand testing' them or doing a 'dry run' which means working through each line of the program on paper to make sure it does what you want it to do. You should do this long before you type in the code.

Task 4. Are these statements true, false, or not mentioned in the text? Correct the false statements.

  1. One of the main factors you should consider when choosing a programming language is the environment in which the language you have chosen is able to operate.

  2. Any required logic can be expressed in three basic structures of pseudocode.

  3. After writing a program systems programmers have to create documentation.

  4. Each step in a flowchart is represented by a different symbol and contains a short description of the process step.

  5. Program is a sequence of instructions written in a defined computer language given to a computer to solve the problem.

  6. Pseudocode has such basic structures as: sequence, decision, branch and loop.

  7. System errors are more insidious and difficult to find.

  8. If there is a logic error in your program, it will run successfully in the sense that the computer will not generate any error messages, but it will not do the right thing.

Task 5. Match English and Russian word-combinations.

1. access program; 2. application program; 3. archived program; 4. binary program; 5. common program; 6. compatible / incompatible program; 7. control / management program; 8. database program; 9. debugging program; 10. free program; 11. general-purpose program; 12. high-performance program; 13. operating (-system) program; 14. processing program; 15. protected-mode program; 16. remote program; 17. running program; 18. self-loading program; 19. simulation program; 20. support program; 21. utility program; 22. virus-detection program; 23. watch-dog program.

a. программа в двоичном коде; b. прикладная программа; c. (не) совместимая программа; d. бесплатная программа; e. программа отладки; f. сторожевая программа; g. дистанционная программа; h. программа моделирования; i. сервисная программа; j. вспомогательная программа; k. программа для доступа (к данным); l. заархивированная программа; m. программа, работающая с базой данных; n. программа, выполняемая с большой скоростью; o. самозагружающаяся программа; p. универсальная программа; q. программа, выполняемая в защищенном режиме; r. программа обработки данных; s. программа операционной системы (системная программа); t. выполняемая программа; u. часто используемая (распространенная) программа; v. программа управления; w. программа обнаружения вирусов.

Task 6. Give the Russian equivalents to the following words and phrases from the text. Choose five of them and make up sentences of your own. Read your sentences aloud for other students to translate.

To run the program, the process of preparing a set of coded instructions, to solve specific problems, the encoding of the program by means of algorithms, to perform functions, to make changes to the program, the problem expressed in mathematical terms, specially processed for the computer, to guard against the errors, to develop logic plans, to indicate the direction of program flow, the essence of computer programming, to produce a system error message, to restart the computer, to report structural errors in a program, to get rid of logic errors, to run the program, to work through each line of the program, less time-consuming, a sensible way of avoiding system errors, to cause the program to fail.

Task 7. Match the words and word-combinations on the left with the definitions on the right.

  1. flowchart

  1. change in character or composition, typically in a comparatively small but significant way

  1. guard against

  1. able to be used or obtained, at someone’s disposal

  1. CPU

  1. a way of carrying out a particular task

  1. bug

  1. programming structure where two different paths can be followed, depending on whether given conditions are true or false

  1. branch

  1. protect against damage or harm

  1. alter

  1. programming structure where a part of the program is repeated a fixed number of times or until condition is met

  1. loop

  1. an error in a computer program or system

  1. solve

  1. find the answer to, explanation for, or means of effectively dealing with a problem

  1. available

  1. cease to work properly, break down

  1. technique

  1. diagrams to show the sequence of logical steps in a program

  1. pseudocode

  1. a notation resembling the programming language, used in the program design

  1. fail

  1. the part of a computer in which operations are controlled and executed

Task 8. Translate the sentences into English using active vocabulary.

  1. Для того чтобы запустить программу, необходимо дважды кликнуть мышью по ярлыку программы.

  2. Искусство программирования состоит в том, чтобы выбрать один из языков программирования, наиболее подходящий для решения задачи.

  3. Нет способа избежать логических ошибок – надо быть внимательным при написании кода и правильно его отлаживать.

  4. Компьютерная программа – это система команд, которая управляет действиями компьютера.

  5. Выбор языка программирования зависит от некоторых факторов, например, совместимости программы с оперативной системой, а также личных способностей и знаний программиста.

  6. Блок-схема – один из способов планирования логической последовательности выполнения программы, описывающий алгоритмы или процессы в форме наглядного представления, использующего заранее заданные символы для иллюстрации логики программы.

  7. Синтаксическая ошибка может привести к завершению всей программы.

  8. Вы можете избавиться от логических ошибок в простых программах посредством выполнения тестирования вручную или метода “тестового прогона”.

  9. Для профессионального программиста псевдокод менее трудоемок, чем построение блок-схемы.

  10. Одним из основных этапов разработки программы является отладка, состоящая в выявлении и устранении программных ошибок, факт существования которых уже установлен.

LISTENING

Task 9. Programmers sometimes use flowcharts when planning a program. Listen to Part 1 of the recording to identify these symbols used in flowcharts. Before listening make sure you understand the meaning of these words and word combinations. If not, check the translation at the end of the unit.

Circle, path, rectangle, sloping side, diamond shape, decision, comparison function, sales tax, initial cost, to charge, rate, amount.

Скругленный прямоугольник 8

Параллелограмм 7

Полотно 6

Полотно 4

Полотно 2

a_______

b_________

c _________

d _________

e _________

Task 10. Listen to Part 1 again. This time write in each symbol a typical example of an instruction often found in flowcharts. Remember that one symbol has no words.

Task 11. Listen to Part 2 of the recording which describes this flowchart for calculating sales tax. As you listen, fill in the gaps where necessary.

Calculating sales taxes

PROBLEM-SOLVING

Task 12. Draw a flowchart for one of these activities. Then compare your completed flowchart with other students in your group.

  • using a payphone

  • planning a holiday

  • choosing a new computer

  • preparing for an important exam

WRITING

Task 13. Read the description of the flowchart (Table 1, p.14). Then write your own description of the flowchart below.

A 'Start' symbol indicates where the program begins. When the program has started, the initial cost of the item is input. A decision is then taken on which rate of tax to use. This depends on the initial cost. If the cost is greater than 100, the program follows the 'Yes' route and sets the tax rate at 15%. Otherwise the program follows the 'No' route and sets the tax rate at 10%. The two different paths then come back together at the 'connector' symbol and follow the same route. The actual sales tax is now calculated by multiplying the cost by the tax rate. Finally the amount of tax is printed out and the program stops.

NOTE

Words for Tasks 9, 10, 11.

circle

круг, окружность

path

syn. route

путь, маршрут

rectangle

прямоугольник

sloping side

наклонная сторона

diamond shape

ромбовидная форма

decision

решение, выбор

comparison function

функция сравнения

sales tax

налог с продаж

initial cost

начальная стоимость

to charge

взыскивать

rate of tax

ставка налогового обложения

amount

сумма

Table 1. Flowchart

Соседние файлы в предмете [НЕСОРТИРОВАННОЕ]