Académique Documents
Professionnel Documents
Culture Documents
LECTURE 1
Objectives
In this chapter, you will:
Learn about different types of computers Explore the hardware and software components of a computer system Learn about the language of a computer Learn about the evolution of programming languages Examine high-level programming languages
LECTURE 1 2
Objectives (cont.)
Discover what a compiler is and what it does Examine a C++ program Explore how a C++ program is processed Become aware of Standard C++ and ANSI/ISO Standard C++
Why Program?
Computer programmable machine designed to follow instructions Program instructions in computer memory to make it do something Programmer person who writes instructions (programs) to make computer perform a task SO, without programmers, no programs; without programs, a computer cannot do anything
4
Categories of Computers
Supercomputers Mainframe computers Minicomputers Microcomputers (personal computers) Mobile computers
LECTURE 1
Computer Components
Computer is an electronic device, with two major components.
Computer Hardware Software
Computer Hardware
Hardware refers to the physical parts of the computer that have mass (they can be touched) Hardware for a typical computer system include the following components
LECTURE 1
LECTURE 1
10
CPU Organization
11
Main Memory
It is volatile. Main memory is erased when program terminates or computer is turned off Also called Random Access Memory (RAM) Organized as follows:
bit: smallest piece of memory. Has values 0 (off, false) or 1 (on, true) byte: 8 consecutive bits. Bytes have addresses.
12
Main Memory
Addresses Each byte in memory is identified by a unique number known as an address.
The number 149 is stored in the byte with the address 16, and the number 72 is stored at address 23.
LECTURE 1 13
Memory Cells
Address Contents
0 1 2 3 4 5 6 ... 999
14
LECTURE 1
Secondary Storage
Non-volatile: data retained when program is not running or computer is turned off Comes in a variety of media:
magnetic: floppy disk, zip disk, hard drive optical: CD-ROM Flash drives, connected to the USB port
15
Input Devices
Devices that send information to the computer from outside Many devices can provide input:
Keyboard, mouse, scanner, digital camera, microphone Disk drives and CD-ROM (Secondary storage)
16
Output Devices
Output is information sent from a computer program to the outside world. The output is sent to an output device Many devices can be used for output:
Computer monitor and printer Floppy, zip disk drives, writable CD drives (Secondary storage)
17
Computer Software
Software: refers to a program that resides and executes electronically on the hardware. Software is divided into 2 categories
Software
System Software
Application Software
18
System Software
Related software that manages the systems resources and control the operations of the hardware. Normally supplied by the manufacturer of the computer. Consists of utility programs and operating aids that facilitate the use and performance of the computer. System programs take control of the computer, such as an operating system. Operating system are programs that manage the computer hardware and the programs that run on them. Examples: Windows, UNIX, Linux.
19
Application Software
Programs that provide services (problem solution) to the user. Designed to perform a specific task (such as course registration or banking) OR a general-purpose task (such as word processing, eg. Ms Word). May be acquired by purchasing off-the-shelf or by designing for own purpose (custom made). Off-the-shelf : General-purpose task. Prewritten and ready to use. Custom made: Specific task. Written by in-house, consulting firm or software house.
20
21
Computing Environment
Personal Computing
Time-Sharing
Client / Server Computing Internet Computing
22
LECTURE 1
23
Time-sharing environment
24
25
Clients (Browser)
26
Binary code:
A sequence of 0s and 1s
Byte:
A sequence of eight bits
27
28
Coding Schemes
ASCII (American Standard Code for Information Interchange)
128 characters A is encoded as 1000001 (66th character) 3 is encoded as 0110011
29
Unicode
65536 characters Two bytes are needed to store a character
30
Computer language evolution The only language understood by a computer is machine language
31
32
33
34
35
37
Low-level: used for communication with computer hardware directly. Often written in binary machine code (0s/1s) directly.
38
39
Program Development
A computer understands a program only if the program is coded in its machine language.
Programmer have to write the program and turn it into an executable (machine language) code.
Programmer have to understand the problem -> break into actions (write program)-> execute by the computer.
41
a)
b) c)
d)
There are 4 steps in the process : Create and edit file containing the program (source code) with a text editor. Run preprocessor to process the preprocessor directives (begin with #) Run compiler to: Check that the program obeys the rules Translate into machine language (object code) Run linker to connect hardware-specific code to machine instructions, producing an executable code. Steps bc are often performed by a single command or button click (compile using the compiler). Errors detected at any step will prevent execution of following steps. 42
Programmer
Code
Code
Executable Code
43
Execution:
The last step is to execute the program
44
45
46
47
49