Upload
redunikorn
View
216
Download
0
Embed Size (px)
Citation preview
7/30/2019 BTKR1343 - Chapter 1 - Intro to Computer
1/49
LECTURE 1 1
BTKR1343
Introduction To Computers
And Programming Language
7/30/2019 BTKR1343 - Chapter 1 - Intro to Computer
2/49
LECTURE 1 2
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
Objectives
7/30/2019 BTKR1343 - Chapter 1 - Intro to Computer
3/49
3
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++
7/30/2019 BTKR1343 - Chapter 1 - Intro to Computer
4/49
4
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; withoutprograms, a computer cannot do anything
7/30/2019 BTKR1343 - Chapter 1 - Intro to Computer
5/49
LECTURE 1 5
Categories of Computers
Supercomputers
Mainframe computers
Minicomputers Microcomputers (personal computers)
Mobile computers
7/30/2019 BTKR1343 - Chapter 1 - Intro to Computer
6/49
6
Computer is an electronic device, with
two major components.
Computer
Hardware Software
Computer Components
7/30/2019 BTKR1343 - Chapter 1 - Intro to Computer
7/49
LECTURE 1 7
Hardware refers to the physical parts of the
computer that have mass (they can be touched)
Hardware for a typical computer system includethe following components
Computer Hardware
7/30/2019 BTKR1343 - Chapter 1 - Intro to Computer
8/49
LECTURE 1 8
Main Hardware Component
Categories:
1. Central Processing Unit (CPU)
2. Primary Storage or Main Memory
3. Auxiliary or Secondary Storage
4. Input Devices
5. Output Devices
7/30/2019 BTKR1343 - Chapter 1 - Intro to Computer
9/49
9
Main Hardware Component
Categories
7/30/2019 BTKR1343 - Chapter 1 - Intro to Computer
10/49
10
Central Processing Unit (CPU)
Brain of the computer
Comprised of:
Control Unit
Retrieves and decodes program instructions
Coordinates activities of all other parts of computer
Arithmetic & Logic Unit Hardware optimized for high-speed numeric
calculation
Hardware designed for true/false, yes/no decisions
7/30/2019 BTKR1343 - Chapter 1 - Intro to Computer
11/49
11
CPU Organization
7/30/2019 BTKR1343 - Chapter 1 - Intro to Computer
12/49
12
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.
7/30/2019 BTKR1343 - Chapter 1 - Intro to Computer
13/49
LECTURE 1 13
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.
7/30/2019 BTKR1343 - Chapter 1 - Intro to Computer
14/49
14
Memory Cells
Address Contents-27.2
354
0.005-26
H
X
75.62
RTV 001
. . .
0
1
23
4
5
6
. . .
999
LECTURE 1
7/30/2019 BTKR1343 - Chapter 1 - Intro to Computer
15/49
15
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
7/30/2019 BTKR1343 - Chapter 1 - Intro to Computer
16/49
16
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)
7/30/2019 BTKR1343 - Chapter 1 - Intro to Computer
17/49
17
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)
7/30/2019 BTKR1343 - Chapter 1 - Intro to Computer
18/49
18
Computer Software
Software: refers to a program that residesand executes electronically on the hardware.
Software is divided into 2 categories
Software
System Software Application Software
7/30/2019 BTKR1343 - Chapter 1 - Intro to Computer
19/49
19
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 thatfacilitate 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.
7/30/2019 BTKR1343 - Chapter 1 - Intro to Computer
20/49
20
Application Software
Programs that provide services (problem solution) tothe user.
Designed to perform a specific task (such as courseregistration 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.
7/30/2019 BTKR1343 - Chapter 1 - Intro to Computer
21/49
21
Where are the application and
system software?
7/30/2019 BTKR1343 - Chapter 1 - Intro to Computer
22/49
22
Computing Environment
Personal Computing
Time-Sharing
Client / Server
Computing
Internet Computing
7/30/2019 BTKR1343 - Chapter 1 - Intro to Computer
23/49
LECTURE 1 23
Personal computing environment
7/30/2019 BTKR1343 - Chapter 1 - Intro to Computer
24/49
24
Time-sharing environment
7/30/2019 BTKR1343 - Chapter 1 - Intro to Computer
25/49
25
The client/server environment
7/30/2019 BTKR1343 - Chapter 1 - Intro to Computer
26/49
Internet
Server
Server
Clients (Browser)26
The internet environment
7/30/2019 BTKR1343 - Chapter 1 - Intro to Computer
27/49
27
Digital signals are sequences of 0s and 1s
Machine language: language of acomputer
Binary digit (bit): The digit 0 or 1
Binary code:
A sequence of 0s and 1s Byte:
A sequence of eight bits
The Language of a Computer
7/30/2019 BTKR1343 - Chapter 1 - Intro to Computer
28/49
28
7/30/2019 BTKR1343 - Chapter 1 - Intro to Computer
29/49
29
Coding Schemes
ASCII (American Standard Code for
Information Interchange)
128 characters
A is encoded as 1000001 (66th character)
3 is encoded as 0110011
7/30/2019 BTKR1343 - Chapter 1 - Intro to Computer
30/49
30
Coding Schemes (cont.)
EBCDIC
Used by IBM
256 characters
Unicode
65536 characters
Two bytes are needed to store a character
7/30/2019 BTKR1343 - Chapter 1 - Intro to Computer
31/49
31
History Of Computer Languages
Computer language evolution
The only language understood by a computer is
machine language
7/30/2019 BTKR1343 - Chapter 1 - Intro to Computer
32/49
32
1.Machine Language
Computer only understand this language.
Series of 1s and 0s (binary numbers), such as
1011010000000101
Difficult to write.
Low level language
History Of Computer Languages
(cont.)
7/30/2019 BTKR1343 - Chapter 1 - Intro to Computer
33/49
33
Early computers were programmed in
machine language
To calculate wages = rates * hours
in machine language:
100100 010001 //Load
100110 010010 //Multiply
100010 010011 //Store
History Of Computer Languages
(cont.)
7/30/2019 BTKR1343 - Chapter 1 - Intro to Computer
34/49
34
2. Symbolic/Assembly Language Unique to particular computer.
Use mnemonics symbols. E.g. MUL Multiply
Easier to understand.
History Of Computer Languages
(cont.)
7/30/2019 BTKR1343 - Chapter 1 - Intro to Computer
35/49
35
Using assembly language instructions,wages = rates hours
can be written as:
LOAD rate
MULT hour
STOR wages
History Of Computer
Languages (cont.)
7/30/2019 BTKR1343 - Chapter 1 - Intro to Computer
36/49
36
3. High-Level Language
Portable to many different computers. Instruction are coded
Eg. COBOL (Business), FORTRAN (Scientific), BASIC,Pascal, C, C++, C#, Java etc.
Programmers use this to write programs.
Compiler: translates a program written in a high-levellanguage machine language
The equation wages = rate x hours can be writtenin C++ as:
wages = rate * hours;
History Of Computer Languages
(cont.)
7/30/2019 BTKR1343 - Chapter 1 - Intro to Computer
37/49
37
4. Natural Language
Like our natural language (such as English,French, or Chinese)
Its use is still quite limited.
History Of Computer Languages
(cont.)
7/30/2019 BTKR1343 - Chapter 1 - Intro to Computer
38/49
38
Programs and
Programming Languages
Types of languages:
High-level: closer to human
language
Low-level: used for
communication with computerhardware directly. Often writtenin binary machine code (0s/1s)directly.
7/30/2019 BTKR1343 - Chapter 1 - Intro to Computer
39/49
39
Some Well-Known High-Level
Programming Languages
7/30/2019 BTKR1343 - Chapter 1 - Intro to Computer
40/49
40
#include using namespace std;
int main()
{
cout
7/30/2019 BTKR1343 - Chapter 1 - Intro to Computer
41/49
41
Program Development
A computer understands a program only if theprogram 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.
7/30/2019 BTKR1343 - Chapter 1 - Intro to Computer
42/49
42
From a High-level Program to an
Executable Code There are 4 steps in the process :a) Create and edit file containing the program (source
code) with a text editor.
b) Run preprocessor to process the preprocessordirectives (begin with #)
c) Run compiler to:
Check that the program obeys the rules
Translate into machine language (object code)
d) 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 offollowing steps.
7/30/2019 BTKR1343 - Chapter 1 - Intro to Computer
43/49
43Executable Code
Code
Code
Programmer
From a High-level Program to an Executable Code
Programmer
7/30/2019 BTKR1343 - Chapter 1 - Intro to Computer
44/49
44
Loader:
Loads executable code/program into main
memory
Execution:
The last step is to execute the program
Program Development (cont.)
7/30/2019 BTKR1343 - Chapter 1 - Intro to Computer
45/49
45
I t t d D l t
7/30/2019 BTKR1343 - Chapter 1 - Intro to Computer
46/49
46
Integrated Development
Environments (IDEs)
An integrated development environment,
or IDE, combine all the tools needed to
write, compile, and debug a program into asingle software application.
Examples are Microsoft Visual C++,
Borland C++ Builder, CodeWarrior, etc.
I t t d D l t
7/30/2019 BTKR1343 - Chapter 1 - Intro to Computer
47/49
47
Integrated Development
Environments (IDEs)
7/30/2019 BTKR1343 - Chapter 1 - Intro to Computer
48/49
48
ANSI/ISO Standard C++
C++ evolved from C
C++ designed by Bjarne Stroustrup at Bell
Laboratories in early 1980s
C++ programs were not always portable
from one compiler to another
In mid-1998, ANSI/ISO C++ language
standards were approved
P f i l Ethi f
7/30/2019 BTKR1343 - Chapter 1 - Intro to Computer
49/49
49
Professional Ethics for
Computer Programmers
Privacy and Misuse of Data
Computer Hacking
Plagiarism and Software Piracy Misuse of a Computer Resource
-the end-