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

Write in c

When I find my 1) ________

in tons of trouble

Friends and colleagues come to me,

Speaking words of 2) ________…

“Write in C”

And as the 3) ________ fast approaches,

And 4) ________ are all that I can see

Somewhere 5) ________ whispers:

“Write in C”

Write in C, write in C,

Write in C, oh, write in C,

6) ________ dead and buried,

Write in C

I used to write a lot of 7) ________

For 8) ________ it worked flawlessly

Try using it for 9) ________!

Write in C!

And if you’ve just spent nearly

10) ________

Debugging some 11) ________

Soon you will be glad to

Write in C

Write in C, write in C,

Write in C, oh, write in C,

12) ________ not the 13) ________,

Write in C

Write in C, write in C,

Write in C, oh, write in C,

14) ________ won’t quite cut it,

Write in C!

Speaking

Task 11. Look at the picture above. Then work in pairs or in small groups and discuss why C-like languages are so popular nowadays. Make a list of reasons.

Task 12. Read the statements below. Which do you agree with more? Why?

‘Learning a programming language is like learning any natural language. The only difference is that you are communicating with a machine instead of another person.’

‘I get annoyed when I hear people comparing programming languages with natural languages. They have almost nothing in common.’

Writing

Task 13. Write an essay (120 – 180 words) summarizing all your ideas in Task 12.

Unit 5. Structured Programming

Warm-up

Task 1. Answer the following questions:

  1. What is structured programming?

  2. What structured programming languages do you know?

  3. What are the main rules of structured programming?

Reading

Task 2. Read the text below to find answers to the following questions:

  1. What was the approach to writing software in the early days of programming?

  2. Where does the term ‘spaghetti code’ come from?

  3. What are the five tenets of structured programming?

  4. What is the role of the control structure?

  5. What control structures are necessary to write programs?

  6. What does the sequence refer to?

  7. What levels of selection does C++ provide?

  8. What loop structures does C++ provide?

  9. What control structures are the most flexible and powerful for problem-solving?

  10. What control structures are the most common in C++ code?

Structured Programming

Up to this point in your study of computer science and C++, you have created programs which used only sequential execution. So far function main() consisted of a sequence of lines which are executed once, line-by-line. As we add the power of loops and selection, we need to use these tools in a disciplined manner.

In the early days of programming (1960's), the approach to writing software was relatively primitive and ineffective. Much of the code was written with goto statements which transferred program control to another part of the code. Tracing this type of code was an exercise in jumping from one spot to another, leaving behind a trail of lines similar to spaghetti. The term "spaghetti code" comes from trying to trace code linked together with goto statements.

The research of Bohm and Jacopini has led to the rules of structured programming. Here are five tenets of structured programming.

  1. No goto statements are to be used in writing code.

  2. All programs can be written in terms of three control structures: sequence, selection, and iteration.

  3. Each control structure has one entrance point and one exit point. We will sometimes allow for multiple exit points from a control structure using the break statement.

  4. Control structures may be stacked (sequenced) one after the other.

  5. Control structures may be nested inside other control structures.

The control structures of C++ encourage structured programming. Staying within the guidelines of structured programming has led to great productivity gains in the field of software engineering.

There are only three necessary control structures needed to write programs: sequence, selection, and iteration.

Sequence refers to the line-by-line execution as used in your programs so far. The program enters the sequence, does each step, and exits the sequence.

Selection is the control structure allowing choice among different directions. C++ provides different levels of selection:

• One-way selection with an if structure

• Two-way selection with an if-else structure

• Multiple selection with a switch structure.

Iteration refers to looping. C++ provides three loop structures:

while loops

do-while loops

for loops

Of the seven control structures, the if-else and while loop are the most flexible and powerful for problem-solving. The other control structures have their place, but if-else and while are the most common control structures used in C++ code.

Task 3. Complete the following text using the list of words below:

Back in the 1960s, computer programs were difficult to read. The 1) …… languages (FORTRAN and often even assembly languages) frequently used if and 2) …… statements, resulting in "spaghetti-like" 3) …… . Programs were essentially networks of statements, where the execution could 4) …… freely from one statement to another, using 5) …… or unconditional jump statements. This situation led the entire industry to use flow charts. The flow chart was a 6) …… which represented the program as a directed graph that connected 7) …… sections of the code. The execution could branch at the if statements, or could jump to any other 8) …… of the code, using the goto 9) ……. Flow charts helped programmers understand the 10) …… of their code.

statement

conditional

primitive

sequential

code

goto

diagram

section

logic

jump

Task 4. Work in pairs and decipher this limerick:

A programmer started to cuss Because getting to sleep was a fuss As he lay there in bed Looping 'round in his head was: while(!asleep()) sheep++;

Now prepare a similar program for one of the activities in the morning using the following structures: while loops, until loops, if-else, etc.

Language work

Relative clauses with a participle

Relative clauses with a participle are often used in technical descriptions. They allow you to provide a lot of information about a noun using as few words as possible.

We often use –ing and –ed clauses after there is/ there are. For example:

There are only three necessary control structures needed to write programs: sequence, selection, and iteration.

A clause is a part of a sentence. Some clauses begin with –ing or –ed.

Study these examples from the text:

  1. Function main() consisted of a sequence of lines

  2. The most common control structures used in C++ code

  3. A control structure using the break statement

  4. The control structure allowing choice among different directions

We can use the passive participle as in examples 1 and 2.

  1. Function main() consisted of a sequence of lines

= function which is consisted

  1. The most common control structures used in C++ code

= control structures which are used

We can use the active participle as in examples 3 and 4.

  1. A control structure using the break statement

= structure which uses the break statement

  1. The control structure allowing choice among different directions

= structure which allows choice among different directions

Task 5. Complete these definitions with the correct participle of the verb given in brackets.

  1. Software engineering is the processes (involve) in writing computer software such as designing, coding and testing programs.

  2. Programming standards are rules (follow) by computer programmers who are working in a team so that their work can be understood by other programmers.

  3. Iteration is the process of a computer (execute) a command or statement again and again until a result is obtained.

  4. GOTO instruction is a high-level programming language instruction (cause) a jump to another place in the program.

  5. While loop is a block of statements in a computer programming language (execute) again and again if a test at the start of the block shows that the execution should happen.

  6. Control structure is one or more statements in a programming language (control) how the program is executed.

Task 6. Link these statements using a relative clause with a participle.

  1. The software company sent me a brochure. The brochure contained all the information I needed.

  2. High-level languages are more efficient. High-level languages allow the programmer to express with one statement what would take several commands in machine language.

  3. External documentation is the printed set of instructions. They describe how to operate the program.

  4. Most computer installations have a standard language. It is used by their programmers.

  5. In addition to the traditional languages, organizations may choose to generate programs. The organizations use data base management systems. The programs use the query language of the DBMS.

  6. Many organizations have a substantial number of computers in operation. Computers are located far apart.

  7. Expert systems are software packages. They are designed to assist humans in situations in which an expert in a specific area is required.

  8. Expert systems will be able to infer answers from sets of data. They emulate humanlike thought processes.

  9. Graphics was an esoteric specialty. It involves expensive display hardware, substantial computer resources, and idiosyncratic software.

  10. The letters are stored in a subdirectory. This subdirectory is called ‘correspondence’ on the C drive.

Translation

Task 7. Match the terms with the correct definition or explanation:

    1. Structured programming

    1. Implementation

    1. Algorithm

    1. Description

    1. Pseudocode

    1. Subdirectory

    1. Computer program

    1. Code

      1. a set of unambiguous rules to solve a problem in a definite number of steps

      2. code that contains a combination of a programming language such as C, and natural language such as English

      3. a directory that is inside another directory

      4. the act of starting to use a plan or computer system

      5. a general term for computer programming instructions

      6. a statement that explains what something looks like, or how it behaves

      7. a method of designing a computer program so that it is easy to understand, change and maintain

      8. a set of instructions that can be understood by a computer and perform a certain task or function

Task 8. Translate the following text into Russian. Check the meaning of any unfamiliar technical words in the dictionary.

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