CSE 021 - Lec01 - Intro - 26.10.21
CSE 021 - Lec01 - Intro - 26.10.21
Programming
CSE 021 Fall 2021
1
Lecture Topics
• Introduction to Computers
• How Computer Works?
• Computer Architecture
• Computer Hardware
• Computer Software
• Data Storage in Computers
• Numbering System
2
What is Computer?
• A computer is a programmable electronic device that
manipulates information, or data. It has the ability to store,
retrieve, and process data.
3
Computer Uses
• What do students use computers for?
• Writing papers, searching for articles, sending email, attending
online classes, etc.
• What do employees use computers for at work?
• Analyze data, make presentations, business transactions,
communicate, control machines, etc.
• What do people use computers for in life?
• Paying bills, shopping online, communicating, playing games and
videos, etc.
4
How Computers Work?
Process
Input Output
5
Computer Architecture
(von Neumann Machine)
• Computer is a system composed of several components that
all work together.
Central Processing Unit (CPU)
Control Unit
Input Output
Devices Devices
Arithmetic Logic
Unit (ALU)
Memory Unit
Primary Secondary
Storage Storage
6
Computer Hardware
• Computer hardware comprises the physical parts or devices
that make up a computer.
• It includes the all-important components of the central
processing unit (CPU) and main memory.
• It also includes peripheral components such as a keyboard,
monitor, mouse, and printer.
7
Fundamental Hardware
Components
• Central Processing Unit (CPU)
• The “brain” of a computer system, which interprets and executes
instructions and programs.
• Main memory
RAM
• Is where currently executing programs reside.
• It is volatile, the contents are lost when the power is turned off.
• Secondary memory
• Provides long-term storage of programs and data.
• Nonvolatile, the contents are retained when power is turned off.
• Can be magnetic (hard drive), optical (CD or DVD), or
flash memory (USB drive). HDD
8
The CPU
• Central Processing Unit (CPU): the part of the computer that
actually runs programs
• Most important component
• Without it, cannot run software
• Used to be a huge device
• Microprocessors: CPUs located on small chips
9
Main Memory
• Main memory: where computer stores a program while
program is running, and data used by the program
• Known as Random Access Memory or RAM
• CPU is able to quickly access data in RAM
• Volatile memory used for temporary storage while program is
running
• Contents are erased when computer is off
10
Secondary Storage Devices
• Secondary storage: can hold data for long periods of time
• Programs normally stored here and loaded to main memory when
needed
• Types of secondary memory
• Disk drive: magnetically encodes data onto a spinning circular disk
• Solid state drive: faster than disk drive, no moving parts, stores
data in solid state memory
• Flash memory: portable, no physical disk
11
Input and Output Devices
• The key distinction between an input device and an output
device is that:
• an input device sends data to the computer, whereas
• an output device receives data from the computer.
• Data can be text, bit stream, image, tactile, audio, and video.
• For example:
• Using a microphone to record a podcast is an example of using an input
device.
• Listening to the recorded podcast through a connected speaker is an
example of using an output device.
• Both output and input devices are examples of auxiliary or peripheral
devices.
12
Input Devices
• The physical part/device that sends information to a
computer system for processing.
Mouse Microphone
Keyboard
Scanner
13
Output Devices
• The physical part/device that receives processed data from
the computer system.
Printer
Monitor Projector
Headphone
Speaker GPS
14
Input or Output Devices?
External Hard
CD/DVD Disk Touch Screen
SD Card
USB Flash Drive
Interactive Board
15
Computer Software
• Everything the computer does is controlled by software.
• General categories:
• Application software
• System software
• Application software: programs that make computer useful
for every day tasks and fulfills users’ needs
• Examples: word processing, email, games, and Web browsers
16
System Software
• System software are programs that control and manage
basic operations of a computer
• Operating system: controls operations of hardware components
• Utility Program: performs specific task to enhance computer
operation or safeguard data
• Virus scanners, file compression, data backup
• Software development tools used to create, modify, and test
software programs
• Compilers, interpreters, assemblers
17
Operating System
• An operating system is the most fundamental set of
programs on a computer.
• The operating system …
• controls the internal operations of the computer’s hardware
• manages all of the devices connected to the computer
• allows data to be saved to and retrieved from storage devices
• allows other programs to run on the computer.
18
Popular Operating Systems
• For laptop and desktop computers include Windows, macOS,
and Linux.
19
Computer Programs
• Computers can be programmed
• Designed to do any job that a program tells them to
• Program: set of instructions that a computer follows to
perform a task
• Commonly referred to as Software
• Programmer: person who can design, create, and test
computer programs
• Also known as software developer
20
How Computers Store Data?
• All data in a computer is stored in sequences of 0s and 1s
21
Byte and Bit
• When a piece of data is stored in a byte, the computer sets
the eight bits to an on/off pattern that represents the data
• For example, the pattern that shows how “01001101” would be
stored in a byte is:
Can you
guess what
number is
this
7 6 5 4 3 2 1 0
22
Storing Numbers
• Bit represents two values, 0 and 1
• Computers use binary numbering system
• Position of digit j is assigned the value 2j-1
• To determine value of binary number sum position values of the 1s
23
Storing Numbers Examples
• Example 1: Storing 157 (< 255)
24
Storing Characters
• Data stored in computer must be stored as binary number.
• So how does a computer store characters when pressed on
the keyboard
25
Storing Characters
• Characters are converted to numeric code, numeric code
stored in memory.
65
26
ASCII Characters Types
Control Special
Numbers Letters
Characters Characters
backspace $ 0 A
escape ? 1 B
carriage return < 6 a
} 9 z
27
ASCII Table
28
Other Types of Data
• Digital: describes any device that stores data as binary
numbers
• Digital images are composed of pixels (picture element)
• To store images, each pixel is converted to a binary number
representing the pixel’s color
29
Numbering Systems
• A numbering system is a systematic method for representing
numbers using a particular set of symbols called digits.
• Each numbering system has what is called Base or Radix
• tells how many different individual symbols there are in the system
to represent numbers.
• Given any positive base N, there are N different individual symbols
that can be used to write numbers in that system.
• The range of these numbers varies from 0 to N − 1.
30
Types of Number Systems
• Binary Number System
• Octal Number System
• Decimal Number System
• Hexadecimal Number System
31
Decimal Number System
• The number system that we use in our life is the decimal number
system.
• Decimal number system has base 10 as it uses 10 digits from 0 to 9.
• In decimal number system, the successive positions from the right
represent units, tens, hundreds, thousands, and so on.
• Each position represents a specific power of the base 10.
• For example, the decimal number 1234 consists of the digit 4 in the
units position, 3 in the tens position, 2 in the hundreds position, and 1
in the thousands position. Its value can be written as
• (1 x 1000)+ (2 x 100)+ (3 x 10)+ (4 x 1)
= (1 x 103)+ (2 x 102)+ (3 x 101)+ (4 x 100)
• 1000 + 200 + 30 + 4 = 1234
Binary Number System
• System base = 2
• Has only two symbols or digits (0 or 1).
• The maximum value of a single digit is 1 (base -1)
• Each position of a digit represents a specific power of the base 2.
• This number system is used in computer.
• Example:
• 101012 = (1*24) + (0*23) + (1*22) + (0*21) + (1*20)
= 16 + 0 + 4 + 0 + 1
= 2110
33
Octal Number System
• System base = 8
• Has eight symbols or digits (0,1,2,3,4,5,6,7).
• The maximum value of a single digit is 1 (base -1)
• Each position of a digit represents a specific power of the
base 8.
• Example: Octal Number: 125708
34
Hexadecimal Number System
• System base = 16
• Has 16 symbols or digits. Uses 10 digits and 6 letters
• 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, A, B, C, D, E, F
• Letters represent the numbers starting from 10
A = 10, B = 11, C = 12, D = 13, E = 14, F = 15
• First position in a hexa number represents a 0 power of the
base (16).
• Example: Hexa Number: 19FDE16
35
Numbering Conversion 1
• Decimal to Other Base System
Decimal
10
36
Decimal to Binary Conversion
1. Divide the number by the ‘Base’ (=2)
2. Take the remainder (either 0 or 1) as a coefficient
3. Take the quotient and repeat the division.
Example: (14)10 = (?)2
Quotient Remainder Coefficient
14 /2= 7 0 a0 = 0
7 /2= 3 1 a1 = 1
3 /2= 1 1 a2 = 1
1 /2= 0 1 a3 = 1
Answer: (14)10 = (a3 a2 a1 a0)2 = (1110)2
MSB LSB
37
Decimal to Octal Conversion
1. Divide the number by the ‘Base’ (=8)
2. Take the remainder (from 0 to 7) as a coefficient
3. Take the quotient and repeat the division.
Example: (160)10 = (?)8
Quotient Remainder Coefficient
160 / 8 = 20 0 a0 = 0
20 / 8 = 2 4 a1 = 4
2 /8= 0 2 a2 = 2
38
Decimal to Hexadecimal Conversion
1. Divide the number by the ‘Base’ (=16)
2. Take the remainder (from 0 to 9, and A to F) as a
coefficient
3. Take the quotient and repeat the division.
Example: (44)10 = (?)16
Quotient Remainder Coefficient
44 / 16 = 2 12 a0 = C
2 / 16 = 0 2 a1 = 2
39
Numbering Conversion 2
• Other Base System to Decimal
Decimal
10
40
Other Base System to Decimal
• Example 1: (11101)2 = (?)10
• 111012 = (1*24) + (1*23) + (1*22) + (0*21) + (1*20)
= 16 + 8 + 4 + 0 + 1
= 2910
• Example 2: (142)8 = (?)10
• 1428 = (1*82) + (4*81) + (2*80)
= 64 + 32 + 2
= 9810
• Example 3: (1A5)16 = (?)10
• 1A516 = (1*162) + (A*161) + (5*160)
= 256 + (10*16) + 5
= 42110
41
Numbering Conversion 3
• Other Base System to Non-Decimal
Decimal
10
42
What is the equivalent value
of the number 4B16 in binary
End of Lecture!
Thanks for your Attention!
44