Unit 1. Computer Programming
Unit 1. Computer Programming
Warm-up
Task 1. What do you know about programming? Answer the Internet Quiz.
1. When creating a computer program, the _____ designs the structure of the program.
a. end user
b. systems analyst
c. programmer
d. all of the above
e. none of the above
2. Checking a computer program for errors is called _____.
a. bugging
b. debugging
c. correcting
d. syntaxing
3. The computer itself uses _____ language.
a. natural
b. assembly
c. machine
d. high-level
e. none of the above
4. The language which is best for mathematical models is _____.
a. FORTRAN
b. BASIC
c. Java
d. C
e. COBOL
5. The term BASIC is an acronym for _____.
a. Balanced Assembly System Integrated Code
b. Basic All System Internal Code
c. Beginner's Assembly Syntax Instruction Code
d. Beginner's All-purpose Symbolic Instruction Code
6. A programming language which looks like normal English is a(n) _____ language.
a. normal
b. high-level
c. natural
d. 4GL
7. The process of writing the computer instructions is called _____.
a. coding
b. compiling
c. debugging
d. interpreting
8. The most widely used language for business programs is _____.
a. FORTRAN
b. BASIC
c. Java
d. C
e. COBOL
9. The _____ must decide what a new program is to accomplish.
a. end user
b. systems analyst
c. programmer
d. supervisor
10. Documentation of computer programs is important so that _____.
a. users can learn how to use the program
b. other programmers can know how to maintain the program
c. the programmer can see why the code is written that way while hunting for sources of error
d. all of the above
e. a and b only
Listening
Task 2. Programmers sometimes use flowcharts when planning a program. Listen to the recording and identify these symbols used in flowcharts. Four symbols are not mentioned.
a) ________________ b) _________________ c) _______________
d) ________________ e) _________________ f) _______________
g) ________________ h) _________________ i) _______________
Task 3. Listen again to the recording and write below a typical example of an instruction often found there in flowcharts. One symbol has no words.
a) _____________________________________________________________________
b) _____________________________________________________________________
c) _____________________________________________________________________
d) _____________________________________________________________________
e) _____________________________________________________________________
Reading
Task 4. Look at the algorithmic flowchart on the next page and answer the questions.
1. Which computer commands does it show?
2. How many decisions does the computer make?
3. After the user clicks Save, how many times does the user input data?
4. How many ways of developing the events are possible here?
5. In what case will the program be completed in the shortest way?
Now describe this algorithmic flowchart.
NO YES
NO |
Task. 6. Work in groups and discuss the following questions.
- Have you ever had any problems with the computer?
- What kind of errors do you make with computers?
- How do you behave when things go wrong with a computer?
Listening
Unit 2. Program Design
Warm-up
Task 1. In pairs, try to think of an answer for the question:
What is programming?
Task 4. Read the text and compare your answers for Tasks 2 and 3.
Task 9. Look at the scheme below and describe activities and connections of the evolutionary development.
A programmers
0A young programmers began to work online,
One didn’t pay for Internet, and then there were 9.
9 young programmers used copies that they made,
But one was caught by FBI, and then there were 8.
8 young programmers discussed about heaven,
One said, “It’s Windows 95”, and then there were 7.
7 young programmers found bugs they want to fix,
But one was fixed by the bug, and then there were 6.
6 young programmers were testing the hard drive,
One got the string “Format complete”, and then there were 5.
5 young programmers were running the FrontDoor,
The BBS of one was hacked, and then there were 4.
4 young programmers worked using only C,
One said some good about Pascal, and then there were 3.
3 young programmers didn’t know what to do,
One tried to call the on-line help, and then there were 2.
2 young programmers were testing what they done,
One got a virus in his brain, and then there were 1.
1 young programmer was as mighty as a hero,
But tried to speak with users, and then there were 0.
Boss cried: “Oh, where is the program we must have?!”
And fired one programmer, and then there were FF.
Programming languages
Computers can deal with different kinds of problems if they are given the right 1) …… for what to do. Instructions are first written in one of the 2) ……, e.g. FORTRAN, COBOL, PASCAL, C++, Visual Basic, etc., depending on the type of problem to be solved. A program written in one of these languages is often called a 3) ……, and it cannot be directly processed by the computer until it has been compiled, which means interpreted into 4) …….
In some languages, an interpretable p-code binary is generated, rather than machine language. It is also possible for the 5) …… to write directly in machine code, but this is hardly ever done anymore: instead, when complete low-level control of the target computer is required, programmers resort to 6) ……, whose instructions are mnemonic one-to-one transriptions of the corresponding machine language instructions.
Different programming languages support different styles of programming (called 7) ……), some of which are better suited for a particular task than others. They also require different levels of detail to be handled by the programmer when implementing algorithms, often resulting in a compromise between ease of use and performance.
The program produced after the source program has been converted into machine code is referred to as an 8) …… or object module. This is done by a computer program called the 9) ……, which is unique for each computer.
The compiler is a system program which may be written in any language, but the computer’s operating system is a true systems program which controls the central processing unit, the input, the output, and the secondary memory devices. Another systems program is the 10) ……, which fetches required systems routine and links them to the object module (the source program in machine code). The resulting program is then called the 11) ……, which is the program directly executable by the computer. Although systems programs are part of the software, they are usually provided by the 12) …… of the machine.
1. programming paradigm 2. assembly language 3. high-level languages 4. source program | 5. linkage editor 6. machine code 7. object program 8. load module | 9. programmer 10. manufacturer 11. instructions 12. compiler |
Listening
Task 4. You are going to hear a lecture about programming languages. Listen carefully and decide whether the following statements are true (T) or false (F) in relation to the information in the recording.
| T / F T / F T / F T / F T / F T / F T / F T / F T / F T / F |
Technical factors
· Application requirements: Languages tend to be suited to particular applications. For example, C is widely used for operating system development (UNIX, Linux, and Windows, to name a few), while Perl is useful for text processing, HTTP server CGI programs, and system administration work.
· Platform requirements: The platform on which an application is to be executed may have a limited choice of language implementations available.
· Development time: How quickly could the application be developed in a particular language? (The technical side of this question depends on how understandable the language is, and how easily an application's design can be coded in it; the political side of this question depends on the knowledge of programming staff, training available, or whether programmers with experience in the language can be hired.)
· Portability: Execution platforms for programs tend to change over time (e.g., from DOS to Windows to Windows NT, just to trace the ''Wintel'' lineage). Is the language closely tied to a particular machine, or is the language clearly portable (e.g., Java's clear independence of any particular machine's quirks or implementation)?
Political factors
· Popularity of the language: Popularity, in terms of the size of the marketplace and number of programmers using a language, clearly affects the choice of a language. The choice of a well-known, popular language, such as C, or a lesser-used language, such as Ada, will influence hiring and/or training requirements.
· Economic: Which language tends to be cheapest or most cost effective in previous, similar development efforts? Is the language well-supported by commercial organizations or freeware development communities (i.e., will the language's compilers and development environment be available for the foreseeable future)?
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
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.
a. No goto statements are to be used in writing code.
b. All programs can be written in terms of three control structures: sequence, selection, and iteration.
c. 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.
d. Control structures may be stacked (sequenced) one after the other.
e. 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++;
Across
1. a statement that explains what something looks like, or how it behaves
2. the process of writing and testing programs for computers
3. a pejorative term for code with a complex and tangled control structure, especially one using many GOTOs, exceptions, or other "unstructured" branching constructs
4. the rate of translating a high-level language into machine code
5. a group of items that are in a certain order
6. a human-readable notation for the machine language that a specific computer architecture uses
7. the control structure allowing choice among different directions
8. the information that explains how to use software or hardware
9. a product review performed by a formal team. A number of such reviews may be held during the lifetime of a software project, covering, for example, requirements specification, program specifications, design, and implementation.
10. …… editor - a program that combines one or more files containing object code from separately compiled program modules into a single file containing loadable or executable code
11. part of a computer program, which tells the computer what to do at that stage
12. a set of rules that must be followed when solving a particular problem
13. a way of writing a description of a computer program using a mixture of natural language and computer language code
14. the period of time during which a program is executed
Down
15. the act of starting to use a plan or computer system, etc.
Speaking
Vocabulary
to handle – to deal with or control
diverse – very different from each other and of various kinds
paradigm – a type of smth, a model
to entail – to involve sth that cannot be avoided
vernacular – the language spoken in a particular area or by a particular group, especially one that is not the official or written language
to encompass – to include a large number or range of things
reminiscent – reminding you of sb/sth
to customize – to make or change sth to suit the needs of the owner
Unit 1. Computer Programming
Warm-up