0% found this document useful (0 votes)
10 views15 pages

Lec 2 PF

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
10 views15 pages

Lec 2 PF

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 15

Programming Fundamental

Lecture 2

1
What is a Computer?
An electronic machine that can accept data (input),
manipulate the data according to specified rules (process),
produce results (output), and stores the results for future
use.
A computer consists of a CPU, memory, hard disk, monitor,
printer, and communication devices.

Bus

Storage Communication Input Output


Memory CPU Devices Devices Devices
Devices
2 e.g., Monitor,
e.g., Disk, CD, e.g., Modem, e.g., Keyboard,
and Tape and NIC Mouse Printer
CPU
The central processing unit (CPU) is the brain of a computer.
It retrieves instructions from memory and executes them. The
CPU speed is measured in megahertz (MHz), with 1
megahertz equaling 1 million pulses per second. The speed of
the CPU has been improved continuously. If you buy a PC
now, you can get an Intel Pentium 4 Processor at 3 gigahertz
(1 gigahertz is 1000 megahertz).
Bus

Storage Communication Input Output


Memory CPU Devices Devices Devices
Devices
e.g., Disk, CD, e.g., Modem, e.g., Keyboard, e.g., Monitor,
and Tape and NIC Mouse Printer
3
Memory
Memory is to store data and program instructions for CPU to execute. A memory
unit is an ordered sequence of bytes, each holds eight bits. A program and its data
must be brought to memory before they can be executed. A memory byte is never
empty, but its initial content may be meaningless to your program. The current
content of a memory byte is lost whenever new information is placed in it.

Bus

Storage Communication Input Output


Memory CPU Devices Devices Devices
Devices
e.g., Disk, CD, e.g., Modem, e.g., Keyboard, e.g., Monitor,
and Tape and NIC Mouse Printer

4
How Data is Stored?
Data of various kinds, such as numbers,
characters, and strings, are encoded as a
series of bits (zeros and ones). Memory address Memory content

Computers use zeros and ones because


digital devices have two stable states, . .

which are referred to as zero and one by . .

convention. .
2000
.
01001010 Encoding for character ‘J’
The programmers need not to be 2001 01100001 Encoding for character ‘a’
concerned about the encoding and 2002 01110110 Encoding for character ‘v’
decoding of data, which is performed 2003 01100001 Encoding for character ‘a’
automatically by the system based on 2004 00000011 Encoding for number 3
the encoding scheme.
The encoding scheme varies. For
example, character ‘J’ is represented by
01001010 in one byte.
A byte is the minimum storage unit.
5
Storage Devices
Memory is volatile, because information is lost when the power is
off. Programs and data are permanently stored on storage devices
and are moved to memory when the computer actually uses them.
There are three main types of storage devices:Disk drives (hard
disks), CD drives (CD-R and CD-RW), and Tape drives.

Bus

Storage Communication Input Output


Memory CPU Devices Devices Devices
Devices
e.g., Disk, CD, e.g., Modem, e.g., Keyboard, e.g., Monitor,
and Tape and NIC Mouse Printer

6
Output Devices: Monitor
The monitor displays information (text and graphics). The
resolution and dot pitch determine the quality of the display.

Bus

Storage Communication Input Output


Memory CPU Devices Devices Devices
Devices
e.g., Disk, CD, e.g., Modem, e.g., Keyboard, e.g., Monitor,
and Tape and NIC Mouse Printer

7
Communication Devices
A regular modem uses a phone line and can transfer data in a speed
up to 56,000 bps (bits per second).
A DSL (digital subscriber line) also uses a phone line and can
transfer data in a speed 20 times faster than a regular modem.
A cable modem uses the TV cable line maintained by the cable
company. A cable modem is as fast as a DSL.
Network interface card (NIC) is a device to connect a computer to a
local area network (LAN). The LAN is commonly used in business,
universities, and government organizations.
A typical type of NIC, called 10BaseT, can transfer data at 10 mbps
(million bits per second).
Bus

Storage Communication Input Output


Memory CPU Devices
8 Devices Devices Devices

e.g., Disk, CD, e.g., Modem, e.g., Keyboard, e.g., Monitor,


and Tape and NIC Mouse Printer
Programs
Computer programs, known as software, are
instructions to the computer.

You tell a computer what to do through programs.


Without programs, a computer is an empty machine.
Computers do not understand human languages, so
you need to use computer languages to communicate
with them.

Programs are written using programming languages.


9
Programming Languages
Machine Language Assembly Language High-Level Language

Machine language is a set of primitive instructions


built into every computer. The instructions are in
the form of binary code, so you have to enter binary
codes for various instructions. Program with native
machine language is a tedious process. Moreover
the programs are highly difficult to read and
modify. For example, to add two numbers, you
might write an instruction in binary like this:

1101101010011010
10
Programming Languages
Machine Language Assembly Language High-Level Language

Assembly languages were developed to make


programming easy. Since the computer cannot understand
assembly language, however, a program called assembler is
used to convert assembly language programs into machine
code. For example, to add two numbers, you might write an
instruction in assembly code like this:
ADDF3 R1, R2, R3
Assembly Source File
Machine Code File


ADDF3 R1, R2, R3
Assembler …
1101101010011010
… …

11
Programming Languages
Machine Language Assembly Language High-Level Language

The high-level languages are English-like and easy to learn


and program. For example, the following is a high-level
language statement that computes the area of a circle with
radius 5:
area = 5 * 5 * 3.1415;

12
Popular High-Level Languages
COBOL (COmmon Business Oriented Language)
FORTRAN (FORmula TRANslation)

BASIC (Beginner All-purpose Symbolic Instructional Code)

Pascal (named for Blaise Pascal)

Ada (named for Ada Lovelace)

C (whose developer designed B first)

Visual Basic (Basic-like visual language developed by

Microsoft)
Delphi (Pascal-like visual language developed by Borland)

C++ (an object-oriented language, based on C)

Java (a popular object-oriented language, similar to C++)

C# 13
(a Java-like developed my Microsoft)
Compiling Source Code
A program written in a high-level language is called a
source program. Since a computer cannot understand a
source program.
Program called a compiler is used to translate the
source program into a machine language program
called an object program. The object program is often
then linked with other supporting library code before
the object can be executed on the machine.

Source File Compiler Object File


14 Linker Excutable File
Operating Systems
The operating system (OS) is a
program that manages and User
controls a computer’s
activities.
Application Programs
You are probably using
Windows 98, NT, 2000, XP,
Win 7,8,10,11. Windows is Operating System

currently the most popular


PC operating system. Hardware
Application programs such
as an Internet browser and a
word15
processor cannot run
without an operating system.

You might also like