Professional Documents
Culture Documents
Department
Computer Programming
(MEng 1052)
Lecture 1
Introduction to Computers and
Programming
February, 2015
Computer Systems
A set of instructions for a computer to follow is called a
program.
The collection of programs used by a computer is referred to
as the software for that computer.
The actual physical machines that make up a computer
installation are referred to as hardware.
There are three main classes of computers: PCs,
workstations, and mainframes.
A PC (personal computer) is a relatively small computer
designed to be used by one person at a time. Most home
computers are PCs, but PCs are also widely used in business,
industry, and science.
Computer Systems
A workstation is essentially a larger and more powerful
Computer Systems
The processor, main memory, and sometimes even secondary
Computer Systems
The keyboard and
monitor
are
sometimes thought
of as a single unit
called a terminal.
Computer Systems
In order to store input and to have the equivalent of scratch
Computer Systems
Each memory location contains a string of zeros and ones.
Computer Systems
The number that identifies a byte is called its address.
A data item, such as a number or a letter, can be stored in
one of these bytes, and the address of the byte is then used
to find the data item when it is needed.
If the computer needs to deal with a data item (such as a
large number) that is too large to fit in a single byte, it will
use several adjacent bytes to hold the data item.
In this case the entire chunk of memory that holds the data
item is still called a memory location.
The address of the first of the bytes that make up this
memory location is used as the address for this larger
memory location.
8
Computer Systems
Thus, as a practical matter, you can think of the computers
Computer Systems
10
Computer Systems
Why Eight?
A byte is a memory location that can hold eight bits. What
is so special about eight? Why not ten bits? There are two
reasons why eight is special.
First, eight is a power of 2. (8 is 23.) Since computers use
bits, which have only two possible values, powers of two
are more convenient than powers of 10.
Second, it turns out that eight bits (one byte) are required to
code a single character (such as a letter or other keyboard
symbol).
11
Computer Systems
The memory we have been discussing up until now is the
Computer Systems
A program, for example, is stored in a file in secondary
Computer Systems
Main memory is often referred to as RAM or random access
Computer Systems
You do not normally talk directly to the computer, but
15
Computer Systems
A program is a set of instructions for a computer to follow.
The input to a computer can be thought of as consisting of
16
Computer Systems
Whenever we give a computer both a program to follow
17
Computer programming
What is computer program?
A computer program is a set of instruction written for a
computer in a special programming language such that the
computer can understand to perform a given task
Why programming?
To solve engineering problems with the help of computers
Solve vast, tiresome and timeconsuming practical
engineering problems in less time and less effort
To increase the habit of developing softwares to save time and
money
Generally, to use computer as a problem solving tool
18
High-Level Languages
There are many languages for writing programs.
19
Low-Level Languages
The kind of language a computer can understand is called a
low-level language.
A typical low-level instruction might be the following:
ADD X Y Z
This instruction might mean Add the number in the
memory location called X to the number in the memory
location called Y, and place the result in the memory
location called Z.
The above sample instruction is written in what is called
assembly language. Although assembly language is almost
the same as the language understood by the computer, it
must undergo one simple translation before the computer
can understand it.
20
Low-Level Languages
In order to get a computer to follow an assembly language
21
Compilers
Any high-level language program must be translated into
22
Linker
Any C++ program you write will use some operations (such as
23
25
26
Algorithms
An algorithm is a sequence of precise instructions that
leads to a solution.
Example. Algorithm that determines how many times a
name occurs in a list of names:
1. Get the list of names.
2. Get the name being checked.
3. Set a counter to zero.
4. Do the following for each name on the list: Compare
the name on the list to the name being checked, and if
the names are the same, then add one to the counter.
5. Announce that the answer is the number indicated by
the counter.
27
Program Design
Designing a program is often a difficult task. There is no
29
Program Design
Testing takes place in both phases. Before the program is
30
31
the computer
This process is what is said to be computer programming
32
in words,
as a flowchart ,
in structured code
Flowchart Symbols
34
Flowchart Example
35
End of Lecture 1
Next Lecture
Lecture 2: Introduction to C++
36