Добавил:
Upload Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз: Предмет: Файл:
posobie_dlya_FIT.rtf
Скачиваний:
2
Добавлен:
01.07.2025
Размер:
1.32 Mб
Скачать

Unit 7 programming and programming languages

Ex.1. Read the text and then put these programming steps into the correct order.

Document and maintain the program. Test the program and detect bugs. Make flowchart. Write code and compile. Analyze the problem Debug and correct it if necessary.

Programming is the process of writing a program using a computer language. A program is a set of instructions which a computer uses to do a specific task (e.g. a solution to a maths problem). The only language a PC can directly execute is machine code, which consists of ls and 0s. This language is difficult to write, so we use symbolic languages that are easier to understand. For example, assembly languages use abbreviations such as ADD, SUB, MPY to represent instructions. The program is then translated into machine code by software called an assembler. Machine code and assembly languages are called low-level languages because they are closer to the hardware. Each statement in a program written in a low-level language usually corresponds to one machine instruction. Assembly language might be used for any of three major reasons: speed, control, and preference. Programs written in assembly language usually run faster than those generated by a compiler; use of assembly language lets a programmer interact directly with the hardware (processor, memory, display, and input/output ports).

Compiled language is a language that is translated into machine code prior to any execution, as opposed to an interpreted language, which is translated and executed statement by statement.

High-level languages, however, are closer to human languages; they use forms resembling English, which makes programming easier. The program is translated into machine code by software called a compiler. Some examples are: FORTRAN – used for scientific and mathematical applications; COBOL – popular for business applications; BASIC – used as a teaching language; Visual BASIC is now used to create Windows applications; C – used to write system software, graphics and commercial programs; Java – designed to run on the Web; Java applets are small programs that run automatically on web pages and let you watch animated characters, and play music and games.

The languages used to create Web documents are called markup languages; they use instructions (markups) to format and link text files. Examples are: HTML – the code used to create Web pages; VoiceXML – it makes the Internet content accessible via speech recognition and phone. Instead of using a web browser on a PC, you use a telephone to access voice-equipped websites. You just dial the phone number of the website and then give spoken instructions, commands, and get the required information.

Steps in Writing a Program

To write a program, software developers usually follow these steps. First they try to understand the problem and define the purpose of the program. They design a flowchart, a diagram which shows the successive logical steps of the program. Next they write the instructions in a high-level language (Pascal, C, etc.). This is called coding. The program is then compiled. When the program is written, they test it: they run the program to see if it works and use special tools to detect bugs, or errors. Any errors are corrected until it runs smoothly. This is called debugging, or bug fixing.

Finally, software companies write a detailed description of how the program works, called program documentation. They also have a maintenance program. They get reports from users about any errors found in the program. After it has been improved, it is published as an updated version.

Ex. 2. Match the terms with their definitions.

1. Programming

a) basic language which consists of binary codes;

2. Machine code

b) programming language such as C, Java or Visual BASIC;

3. Assembly language

c) writing computer programs;

4. High-level language

d) low-level language translated into machine code by an assembler;

5. Java applet

e) software which converts a source program into machine code;

6. Compiler

f) language used to create and format documents for the Web;

Ex. 3. Work in groups of three. Read one of the texts below and complete the Table. When you have finished exchange information with the others in your group to complete two similar Tables.

Types of errors

Definition

Example

Ways to avoid or deal with this kind of error

A. 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 massage on the screen, like “printer is not ready or available”.

B. Syntax errors are mistakes in the programming language (like typing PRNIT instead of PAINT). 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.

C. 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 screen end 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. 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.

Ex. 4. Match these problems and solutions.

Problems

Solutions

1. Connect a computer to a telephone line.

a) write code to check a peripheral is present before any data is sent;

2. Identify items for pricing.

b) use the debug command;

3. Add extra facilities to a computer.

c)add more memory;

4. Get more file storage space.

d) format the disk;

5. Find syntax errors.

e) use a removable disk;

6. Avoid marking the surface of a CD-ROM.

f) install and expansion card;

7. Improve the speed of your computer.

g) install a modem;

8. Avoid system errors.

h) fit a bigger hard disk;

9. Prepare a new disk for use.

i) use barcode labels;

10. Transfer information between computers.

j) hold it by the edges.

Ex. 5. Read the text and tell about Object-Oriented Programming.

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