100% found this document useful (1 vote)
1K views1,055 pages

Computer Fundamentals: Pradeep K. Sinha Priti Sinha

Uploaded by

SHWEETA MEHTA
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
100% found this document useful (1 vote)
1K views1,055 pages

Computer Fundamentals: Pradeep K. Sinha Priti Sinha

Uploaded by

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

Computer Fundamentals : Pradeep K.

Sinha & Priti Sinha

Computer Fundamentals

Pradeep K. Sinha
Priti Sinha

Chapter 1

Introduction
Chapter 01: Introduction Slide 1/17
Computer Fundamentals : Pradeep K. Sinha & Priti Sinha

Learning Objectives
In this chapter you will learn about:

 Computer
 Data processing
 Characteristic features of computers
 Computers’ evolution to their present form
 Computer generations
 Characteristic features of each computer generation

Chapter 01: Introduction Slide 2/17


Computer Fundamentals : Pradeep K. Sinha & Priti Sinha

Computer
 The word computer comes from the word “compute”,
which means, “to calculate”

 Thereby, a computer is an electronic device that can


perform arithmetic operations at high speed

 A computer is also called a data processor because it can


store, process, and retrieve data whenever desired

Ref. Page 01 Chapter 01: Introduction Slide 3/17


Computer Fundamentals : Pradeep K. Sinha & Priti Sinha

Data Processing

The activity of processing data using a computer is called


data processing

Data Input Computer Output Information


(Raw material) (Data processor) (Finished product)

Data is raw material used as input to data processing and


information is processed data obtained as output

Ref. Page 01 Chapter 01: Introduction Slide 4/17


Computer Fundamentals : Pradeep K. Sinha & Priti Sinha

Characteristics of Computers
Sr.
Characteristics Description
No.

1 Automatic It carries out a job normally without any human intervention

It can perform several billion (109) simple arithmetic operations


2 Speed
per second

3 Accuracy It performs every calculation with the same accuracy

4 Diligence It is free from monotony, tiredness, and lack of concentration

5 Versatility It can perform a wide variety of tasks

It can store huge amount of information and can recall any piece
6 Memory
of this information whenever required

It cannot take its own decisions, and has to be instructed what


7 No I. Q.
to do and in what sequence

8 No Feelings It cannot make judgments based on feelings and instincts

Ref. Page 03 Chapter 01: Introduction Slide 5/17


Computer Fundamentals : Pradeep K. Sinha & Priti Sinha

Evolution of Computers

Chapter 01: Introduction Slide 6/17


Computer Fundamentals : Pradeep K. Sinha & Priti Sinha

Evolution of Computers
 Blaise Pascal invented the first mechanical adding
machine in 1642
 Baron Gottfried Wilhelm von Leibniz invented the first
calculator for multiplication in 1671
 Keyboard machines originated in the United States
around 1880
 Around 1880, Herman Hollerith came up with the concept
of punched cards that were extensively used as input
media until late 1970s

(Continued on next slide)

Ref. Page 03 Chapter 01: Introduction Slide 7/17


Computer Fundamentals : Pradeep K. Sinha & Priti Sinha

Evolution of Computers

 Charles Babbage is considered to be the father of


modern digital computers

 He designed “Difference Engine” in 1822

 He designed a fully automatic analytical engine in


1842 for performing basic arithmetic functions

 His efforts established a number of principles that


are fundamental to the design of any digital
computer

Ref. Page 03 Chapter 01: Introduction Slide 8/17


Computer Fundamentals : Pradeep K. Sinha & Priti Sinha

Some Well Known Early Computers

 The Mark I Computer (1937-44)


 The Atanasoff-Berry Computer (1939-42)
 The Electronic Numerical Integrator And Calculator (ENIAC)
(1943-46)
 The Electronic Discrete Variable Automatic Computer
(EDVAC) (1946-52)
 The Electronic Delay Storage Automatic Calculator (EDSAC)
(1947-49)
 Manchester Mark I (1948)
 The Universal Automatic Computer (UNIVAC) I (1951)
 IBM 701 (1952)
 IBM 650 (1953)

Ref. Page 05 Chapter 01: Introduction Slide 9/17


Computer Fundamentals : Pradeep K. Sinha & Priti Sinha

Computer Generations

Chapter 01: Introduction Slide 10/17


Computer Fundamentals : Pradeep K. Sinha & Priti Sinha

Computer Generations
 “Generation” in computer talk is a step in technology. It
provides a framework for the growth of computer industry

 Originally it was used to distinguish between various


hardware technologies, but now it has been extended to
include both hardware and software

 Till today, there are five computer generations

(Continued on next slide)

Ref. Page 04 Chapter 01: Introduction Slide 11/17


Computer Fundamentals : Pradeep K. Sinha & Priti Sinha

Computer Generations

Some
Generation Key hardware Key software Key
representative
(Period) technologies technologies characteristics
systems
First • Vacuum tubes  Machine and  Bulky in size  ENIAC
(1942-1955) • Electromagnetic assembly  Highly unreliable  EDVAC
relay memory languages  Limited commercial
 Stored program use commercial  EDSAC
• Punched cards concept production difficult and  UNIVAC I
secondary storage costly
 Mostly scientific  IBM 701
applications  Difficult to use

Second  Transistors  Batch operating  Faster, smaller, more  Honeywell 400


(1955-1964)  Magnetic core system reliable and easier to  IBM 7030
memory  High-level program than previous
programming generation systems  CDC 1604
 Magnetic tapes languages  Commercial production  UNIVAC LARC
 Disks secondary  Scientific and was still difficult and
storage commercial costly
applications

Chapter 01: Introduction Slide 12/17


Computer Fundamentals : Pradeep K. Sinha & Priti Sinha

Computer Generations

Key hardware Key software Key Some


Generation
representative
(Period) technologies technologies Characteristics systems

Third  ICs with SSI and  Timesharing  Faster, smaller, more IBM 360/370
(1964-1975) MSI technologies operating system reliable, easier and  PDP-8
 Larger magnetic cheaper to produce
 Standardization  PDP-11
core memory  Commercially, easier
of high-level  CDC 6600
 Larger capacity to use, and easier to
programming
magnetic disks and upgrade than previous
languages
tapes secondary generation systems
storage  Unbundling of  Scientific, commercial
software from and interactive on-line
 Minicomputers hardware applications

(Continued on next slide)

Ref. Page 15 Chapter 01: Introduction Slide 13/17


Computer Fundamentals : Pradeep K. Sinha & Priti Sinha

Computer Generations
Key hardware Key software Key Some
Generation
representative
(Period) technologies technologies Characteristics systems
Fourth  ICs with VLSI  Operating systems for  Small,  IBM PC and its
(1975-1989) technology PCs with GUI and Multiple affordable, clones
 Microprocessors; windows on a single reliable, and easy  Apple II
semiconductor terminal screen to use PCs
 Multiprocessor operating  More powerful  TRS-80
memory
systems and concurrent and reliable  VAX 9000
 Larger capacity programming languages mainframe
hard disks as in-  CRAY-1
 UNIX operating system systems
built secondary  General purpose  CRAY-2
storage  C and C++
programming languages machines  CRAY-X/MP
 Magnetic tapes  PC-based applications;  Easier to
and floppy disks as produce
network-based
portable storage commercially
applications
media
 Object-oriented software
 Personal design
computers
 Spread of high-
speed computer
networks (Continued on next slide)

Ref. Page 15 Chapter 01: Introduction Slide 14/17


Computer Fundamentals : Pradeep K. Sinha & Priti Sinha

Computer Generations
Key hardware Key software Key Some
Generation
representative
(Period) technologies technologies Characteristics systems
Fifth  ICs with ULSI  World Wide  Portable computers  iPhone
(1989- technology Web  Hand-held mobile  iPad
Present)  Multicore processor  Multimedia, smart devices
chips  More powerful,  IBM notebooks
Internet-based
 Larger capacity main applications cheaper, reliable, and  Pentium PCs
memory and hard disks easier to use desktop  Windows PC
 Microkernel, machines
 Optical disks as multithreading,  Apple PC
portable read-only  Very powerful
multicore OS
storage media mainframes  SUN
 JAVA, Python  Very high uptime Workstations
 Solid state disks and other due to hot-pluggable  IBM SP/2
 Notebook computers programming components
 Powerful desktop PCs languages  SGI Origin 2000
 General purpose
and workstations  MPI and PVM  PARAM
machines
 Very powerful libraries for supercomputers
mainframes  Easier to produce
parallel commercially
 Supercomputers based programming
on parallel processing
 Internet
(Continued on next slide)

Ref. Page 15 Chapter 01: Introduction Slide 15/17


Computer Fundamentals : Pradeep K. Sinha & Priti Sinha
Electronic Devices Used in Computers of Different
Generations

(a) A Vacuum tube (b) A Transistor (c) An IC chip

Ref. Page 07 Chapter 01: Introduction Slide 16/17


Computer Fundamentals : Pradeep K. Sinha & Priti Sinha

Key Words/Phrases

 Computer  Integrated Circuit (IC)


 Computer generations  Large Scale Integration (VLSI)
 Computer Supported Cooperative  Medium Scale Integration (MSI)
Working (CSCW)  Microprocessor
 Data  Personal Computer (PC)
 Data processing  Second-generation computers
 Data processor  Small Scale Integration (SSI)
 First-generation computers  Stored program concept
 Second-generation computers  Third-generation computers
 Third-generation computers  Transistor
 Fourth-generation computers  Ultra Large Scale Integration (ULSI)
 Fifth-generation computers  Vacuum tubes
 Garbage-in-garbage-out (GIGO)
 Graphical User Interface (GUI)
 Groupware
 Information

Chapter 01: Introduction Slide 17/17


Computer Fundamentals: Pradeep K. Sinha & Priti Sinha

Computer Fundamentals

Pradeep K. Sinha
Priti Sinha

Chapter 2

Basic Computer
Organization
Chapter 02: Basic Computer Organization Slide 1/19
Computer Fundamentals: Pradeep K. Sinha & Priti Sinha

Learning Objectives
In this chapter you will learn about:
 Basic operations performed by all types of computer
systems
 Basic organization of a computer system
 Input unit and its functions
 Output unit and its functions
 Storage unit and its functions
 Types of storage used in a computer system

(Continued on next slide)

Chapter 02: Basic Computer Organization Slide 2/19


Computer Fundamentals: Pradeep K. Sinha & Priti Sinha

Learning Objectives

 Arithmetic Logic Unit (ALU)


 Control Unit (CU)
 Central Processing Unit (CPU)
 Computer as a system

Chapter 02: Basic Computer Organization Slide 3/19


Computer Fundamentals: Pradeep K. Sinha & Priti Sinha
The Five Basic Operations of a
Computer System

 Inputting. The process of entering data and instructions


into the computer system
 Storing. Saving data and instructions to make them
readily available for initial or additional processing
whenever required
 Processing. Performing arithmetic operations (add,
subtract, multiply, divide, etc.) or logical operations
(comparisons like equal to, less than, greater than, etc.)
on data to convert them into useful information

(Continued on next slide)

Ref. Page 18 Chapter 02: Basic Computer Organization Slide 4/19


Computer Fundamentals: Pradeep K. Sinha & Priti Sinha
The Five Basic Operations of a
Computer System

 Outputting. The process of producing useful information


or results for the user such as a printed report or visual
display
 Controlling. Directing the manner and sequence in which
all of the above operations are performed

Ref. Page 18 Chapter 02: Basic Computer Organization Slide 5/19


Computer Fundamentals: Pradeep K. Sinha & Priti Sinha

Basic Organization of a Computer System


Storage Unit

Secondary
Storage

Program Information
Input Output (Results)
and
Unit Unit
Data Primary
Storage

Control
Unit
Indicates flow of
instructions and data
Arithmetic
Indicates the control
Logic Unit
exercised by the
control unit
Central Processing Unit (CPU)

Ref. Page 19 Chapter 02: Basic Computer Organization Slide 6/19


Computer Fundamentals: Pradeep K. Sinha & Priti Sinha

Main Units and


Their Functions

Chapter 02: Basic Computer Organization Slide 7/19


Computer Fundamentals: Pradeep K. Sinha & Priti Sinha

Input Unit
An input unit of a computer system performs the
following functions:

1. It accepts (or reads) instructions and data from outside


world
2. It converts these instructions and data in computer
acceptable form
3. It supplies the converted instructions and data to the
computer system for further processing

Ref. Page 19 Chapter 02: Basic Computer Organization Slide 8/19


Computer Fundamentals: Pradeep K. Sinha & Priti Sinha

Output Unit
An output unit of a computer system performs the
following functions:

1. It accepts the results produced by the computer, which


are in coded form and hence, cannot be easily
understood by us
2. It converts these coded results to human acceptable
(readable) form
3. It supplies the converted results to outside world

Ref. Page 19 Chapter 02: Basic Computer Organization Slide 9/19


Computer Fundamentals: Pradeep K. Sinha & Priti Sinha

Storage Unit
The storage unit of a computer system holds (or stores)
the following :

1. Data and instructions required for processing (received


from input devices)
2. Intermediate results of processing
3. Final results of processing, before they are released to
an output device

Ref. Page 20 Chapter 02: Basic Computer Organization Slide 10/19


Computer Fundamentals: Pradeep K. Sinha & Priti Sinha

Types of Storage
The broad categories of storage are:

1. Primary storage
2. Secondary storage

Ref. Page 20 Chapter 02: Basic Computer Organization Slide 11/19


Computer Fundamentals: Pradeep K. Sinha & Priti Sinha

Primary Storage

 Used to hold running program instructions


 Used to hold data, intermediate results, and
results of ongoing processing of job(s)
 Fast in operation
 Small Capacity
 Expensive
 Volatile (looses data on power dissipation)

(Continued on next slide)

Ref. Page 20 Chapter 02: Basic Computer Organization Slide 12/19


Computer Fundamentals: Pradeep K. Sinha & Priti Sinha

Secondary Storage
 Used to hold stored program instructions
 Used to hold data and information of stored jobs
 Slower than primary storage
 Large Capacity
 Lot cheaper that primary storage
 Retains data even without power

Ref. Page 20 Chapter 02: Basic Computer Organization Slide 13/19


Computer Fundamentals: Pradeep K. Sinha & Priti Sinha

Arithmetic Logic Unit (ALU)


Arithmetic Logic Unit of a computer system is the place
where the actual executions of instructions takes place during
processing operation

Ref. Page 21 Chapter 02: Basic Computer Organization Slide 14/19


Computer Fundamentals: Pradeep K. Sinha & Priti Sinha

Control Unit (CU)


Control Unit of a computer system manages and coordinates
the operations of all other components of the computer
system

Ref. Page 21 Chapter 02: Basic Computer Organization Slide 15/19


Computer Fundamentals: Pradeep K. Sinha & Priti Sinha

Central Processing Unit (CPU)

Arithmetic Central
Logic Unit Control Unit = Processing
+ (CU)
(ALU) Unit (CPU)

 It is the brain of a computer system

 It is responsible for controlling the operations of


all other units of a computer system

Ref. Page 21 Chapter 02: Basic Computer Organization Slide 16/19


Computer Fundamentals: Pradeep K. Sinha & Priti Sinha

The System Concept

Chapter 02: Basic Computer Organization Slide 17/19


Computer Fundamentals: Pradeep K. Sinha & Priti Sinha

The System Concept


A system has following three characteristics:

1. A system has more than one element


2. All elements of a system are logically related
3. All elements of a system are controlled in a manner to
achieve the system goal

A computer is a system as it comprises of integrated


components (input unit, output unit, storage unit, and CPU)
that work together to perform the steps called for in the
executing program

Ref. Page 21 Chapter 02: Basic Computer Organization Slide 18/19


Computer Fundamentals: Pradeep K. Sinha & Priti Sinha

Key Words/Phrases
 Arithmetic Logic Unit (ALU)  Output interface
 Auxiliary storage  Output unit
 Central Processing Unit (CPU)  Outputting
 Computer system  Primate storage
 Control Unit (CU)  Processing
 Controlling  Secondary storage
 Input interface  Storage unit
 Input unit  Storing
 Inputting  System
 Main memory

Chapter 02: Basic Computer Organization Slide 19/19


Computer Fundamentals : Pradeep K. Sinha & Priti Sinha

Computer Fundamentals

Pradeep K. Sinha
Priti Sinha

Chapter 3

Number Systems
Chapter 03: Number Systems Slide 1/43
Computer Fundamentals : Pradeep K. Sinha & Priti Sinha

Learning Objectives
In this chapter you will learn about:

 Non-positional number system


 Positional number system
 Decimal number system
 Binary number system
 Octal number system
 Hexadecimal number system

(Continued on next slide)

Chapter 03: Number Systems Slide 2/43


Computer Fundamentals : Pradeep K. Sinha & Priti Sinha

Learning Objectives
 Convert a number’s base
 Another base to decimal base
 Decimal base to another base
 Some base to another base
 Shortcut methods for converting
 Binary to octal number
 Octal to binary number
 Binary to hexadecimal number
 Hexadecimal to binary number
 Fractional numbers in binary number system

Chapter 03: Number Systems Slide 3/43


Computer Fundamentals : Pradeep K. Sinha & Priti Sinha

Number Systems

Two types of number systems are:

 Non-positional number systems


 Positional number systems

Ref. Page 23 Chapter 03: Number Systems Slide 4/43


Computer Fundamentals : Pradeep K. Sinha & Priti Sinha

Basics and Few Popular


Number Systems

Chapter 03: Number Systems Slide 5/43


Computer Fundamentals : Pradeep K. Sinha & Priti Sinha

Non-positional Number Systems


 Characteristics
 Use symbols such as I for 1, II for 2, III for 3, IIII
for 4, IIIII for 5, etc
 Each symbol represents the same value regardless
of its position in the number
 The symbols are simply added to find out the value
of a particular number

 Difficulty
 It is difficult to perform arithmetic with such a
number system

Ref. Page 23 Chapter 03: Number Systems Slide 6/43


Computer Fundamentals : Pradeep K. Sinha & Priti Sinha

Positional Number Systems


 Characteristics

 Use only a few symbols called digits


 These symbols represent different values depending
on the position they occupy in the number

(Continued on next slide)

Ref. Page 24 Chapter 03: Number Systems Slide 7/43


Computer Fundamentals : Pradeep K. Sinha & Priti Sinha

Positional Number Systems


 The value of each digit is determined by:
1. The digit itself
2. The position of the digit in the number
3. The base of the number system

(base = total number of digits in the number


system)

 The maximum value of a single digit is always equal to


one less than the value of the base

Ref. Page 24 Chapter 03: Number Systems Slide 8/43


Computer Fundamentals : Pradeep K. Sinha & Priti Sinha

Decimal Number System


Characteristics
 A positional number system
 Has 10 symbols or digits (0, 1, 2, 3, 4, 5, 6, 7, 8,
9). Hence, its base = 10
 The maximum value of a single digit is 9 (one less
than the value of the base)
 Each position of a digit represents a specific power
of the base (10)
 We use this number system in our day-to-day life

(Continued on next slide)

Ref. Page 24 Chapter 03: Number Systems Slide 9/43


Computer Fundamentals : Pradeep K. Sinha & Priti Sinha

Decimal Number System

Example

258610 = (2 x 103) + (5 x 102) + (8 x 101) + (6 x 100)

= 2000 + 500 + 80 + 6

Ref. Page 24 Chapter 03: Number Systems Slide 10/43


Computer Fundamentals : Pradeep K. Sinha & Priti Sinha

Binary Number System


Characteristics
 A positional number system
 Has only 2 symbols or digits (0 and 1). Hence its
base = 2
 The maximum value of a single digit is 1 (one less
than the value of the base)
 Each position of a digit represents a specific power
of the base (2)
 This number system is used in computers

(Continued on next slide)

Ref. Page 24 Chapter 03: Number Systems Slide 11/43


Computer Fundamentals : Pradeep K. Sinha & Priti Sinha

Binary Number System


Example

101012 = (1 x 24) + (0 x 23) + (1 x 22) + (0 x 21) x (1 x 20)

= 16 + 0 + 4 + 0 + 1

= 2110

Ref. Page 25 Chapter 03: Number Systems Slide 12/43


Computer Fundamentals : Pradeep K. Sinha & Priti Sinha
Representing Numbers in Different
Number Systems

In order to be specific about which number system we


are referring to, it is a common practice to indicate the
base as a subscript. Thus, we write:

101012 = 2110

Ref. Page 25 Chapter 03: Number Systems Slide 13/43


Computer Fundamentals : Pradeep K. Sinha & Priti Sinha

Bit

 Bit stands for binary digit


 A bit in computer terminology means either a 0 or a 1
 A binary number consisting of n bits is called an n-bit
number

Ref. Page 25 Chapter 03: Number Systems Slide 14/43


Computer Fundamentals : Pradeep K. Sinha & Priti Sinha

Octal Number System


Characteristics
 A positional number system
 Has total 8 symbols or digits (0, 1, 2, 3, 4, 5, 6, 7).
Hence, its base = 8
 The maximum value of a single digit is 7 (one less
than the value of the base
 Each position of a digit represents a specific power of
the base (8)

(Continued on next slide)

Ref. Page 25 Chapter 03: Number Systems Slide 15/43


Computer Fundamentals : Pradeep K. Sinha & Priti Sinha

Octal Number System


 Since there are only 8 digits, 3 bits (23 = 8) are
sufficient to represent any octal number in binary

Example

20578 = (2 x 83) + (0 x 82) + (5 x 81) + (7 x 80)

= 1024 + 0 + 40 + 7

= 107110

Ref. Page 25 Chapter 03: Number Systems Slide 16/43


Computer Fundamentals : Pradeep K. Sinha & Priti Sinha

Hexadecimal Number System


Characteristics
 A positional number system
 Has total 16 symbols or digits (0, 1, 2, 3, 4, 5, 6, 7,
8, 9, A, B, C, D, E, F). Hence its base = 16
 The symbols A, B, C, D, E and F represent the
decimal values 10, 11, 12, 13, 14 and 15
respectively
 The maximum value of a single digit is 15 (one less
than the value of the base)

(Continued on next slide)

Ref. Page 25 Chapter 03: Number Systems Slide 17/43


Computer Fundamentals : Pradeep K. Sinha & Priti Sinha

Hexadecimal Number System


 Each position of a digit represents a specific power
of the base (16)
 Since there are only 16 digits, 4 bits (24 = 16) are
sufficient to represent any hexadecimal number in
binary

Example
1AF16 = (1 x 162) + (A x 161) + (F x 160)
= 1 x 256 + 10 x 16 + 15 x 1
= 256 + 160 + 15
= 43110

Ref. Page 25 Chapter 03: Number Systems Slide 18/43


Computer Fundamentals : Pradeep K. Sinha & Priti Sinha

Converting from One


Number System to Another

Chapter 03: Number Systems Slide 19/43


Computer Fundamentals : Pradeep K. Sinha & Priti Sinha
Converting a Number of Another Base to a
Decimal Number

Method

Step 1: Determine the column (positional) value of


each digit

Step 2: Multiply the obtained column values by the


digits in the corresponding columns

Step 3: Calculate the sum of these products

(Continued on next slide)

Ref. Page 26 Chapter 03: Number Systems Slide 20/43


Computer Fundamentals : Pradeep K. Sinha & Priti Sinha
Converting a Number of Another Base to a
Decimal Number

Example
47068 = ?10
Column values
multiplied
by the
47068 = 4 x 83 + 7 x 82 + 0 x 81 + 6 x 80 corresponding
digits
= 4 x 512 + 7 x 64 + 0 + 6 x 1
= 2048 + 448 + 0 + 6 Sum of these
products
= 250210

Ref. Page 26 Chapter 03: Number Systems Slide 21/43


Computer Fundamentals : Pradeep K. Sinha & Priti Sinha
Converting a Decimal Number to a Number
of Another Base

Division-Remainder Method
Step 1: Divide the decimal number to be converted by
the value of the new base

Step 2: Record the remainder from Step 1 as the


rightmost digit (least significant digit) of the
new base number

Step 3: Divide the quotient of the previous divide by the


new base

(Continued on next slide)

Ref. Page 28 Chapter 03: Number Systems Slide 22/43


Computer Fundamentals : Pradeep K. Sinha & Priti Sinha
Converting a Decimal Number to a Number
of Another Base

Step 4: Record the remainder from Step 3 as the next


digit (to the left) of the new base number

Repeat Steps 3 and 4, recording remainders from right to


left, until the quotient becomes zero in Step 3

Note that the last remainder thus obtained will be the most
significant digit (MSD) of the new base number

(Continued on next slide)

Ref. Page 28 Chapter 03: Number Systems Slide 23/43


Computer Fundamentals : Pradeep K. Sinha & Priti Sinha
Converting a Decimal Number to a Number
of Another Base

Example
95210 = ?8

Solution:
8 952 Remainders
119 0
14 7
1 6
0 1

Hence, 95210 = 16708

Ref. Page 29 Chapter 03: Number Systems Slide 24/43


Computer Fundamentals : Pradeep K. Sinha & Priti Sinha
Converting from a Base Other Than 10 to
Another Base Other Than 10

Method

Step 1: Convert the original number to a decimal


number (base 10)

Step 2: Convert the decimal number so obtained to


the new base number

(Continued on next slide)

Ref. Page 30 Chapter 03: Number Systems Slide 25/43


Computer Fundamentals : Pradeep K. Sinha & Priti Sinha
Converting from a Base Other Than 10 to
Another Base Other Than 10

Example
5456 = ?4

Solution:
Step 1: Convert from base 6 to base 10

5456 = 5 x 62 + 4 x 61 + 5 x 60
= 5 x 36 + 4 x 6 + 5 x 1
= 180 + 24 + 5
= 20910

(Continued on next slide)

Ref. Page 30 Chapter 03: Number Systems Slide 26/43


Computer Fundamentals : Pradeep K. Sinha & Priti Sinha
Converting from a Base Other Than 10 to
Another Base Other Than 10
Step 2: Convert 20910 to base 4

4 209 Remainders
52 1
13 0
3 1
0 3

Hence, 20910 = 31014

So, 5456 = 20910 = 31014

Thus, 5456 = 31014

Ref. Page 31 Chapter 03: Number Systems Slide 27/43


Computer Fundamentals : Pradeep K. Sinha & Priti Sinha
Shortcut Method for Converting a Binary
Number to its Equivalent Octal Number

Method
Step 1: Divide the digits into groups of three starting
from the right

Step 2: Convert each group of three binary digits to


one octal digit using the method of binary to
decimal conversion

(Continued on next slide)

Ref. Page 32 Chapter 03: Number Systems Slide 28/43


Computer Fundamentals : Pradeep K. Sinha & Priti Sinha
Shortcut Method for Converting a Binary
Number to its Equivalent Octal Number

Example
11010102 = ?8

Step 1: Divide the binary digits into groups of 3 starting


from right

001 101 010

Step 2: Convert each group into one octal digit

0012 = 0 x 22 + 0 x 21 + 1 x 20 = 1
1012 = 1 x 22 + 0 x 21 + 1 x 20 = 5
0102 = 0 x 22 + 1 x 21 + 0 x 20 = 2

Hence, 11010102 = 1528

Ref. Page 32 Chapter 03: Number Systems Slide 29/43


Computer Fundamentals : Pradeep K. Sinha & Priti Sinha
Shortcut Method for Converting an Octal
Number to Its Equivalent Binary Number

Method
Step 1: Convert each octal digit to a 3 digit binary
number (the octal digits may be treated as
decimal for this conversion)

Step 2: Combine all the resulting binary groups


(of 3 digits each) into a single binary
number

(Continued on next slide)

Ref. Page 32 Chapter 03: Number Systems Slide 30/43


Computer Fundamentals : Pradeep K. Sinha & Priti Sinha
Shortcut Method for Converting an Octal
Number to Its Equivalent Binary Number

Example
5628 = ?2

Step 1: Convert each octal digit to 3 binary digits


58 = 1012, 68 = 1102, 28 = 0102

Step 2: Combine the binary groups


5628 = 101 110 010
5 6 2

Hence, 5628 = 1011100102

Ref. Page 33 Chapter 03: Number Systems Slide 31/43


Computer Fundamentals : Pradeep K. Sinha & Priti Sinha
Shortcut Method for Converting a Binary
Number to its Equivalent Hexadecimal Number

Method

Step 1: Divide the binary digits into groups of four


starting from the right

Step 2: Combine each group of four binary digits to


one hexadecimal digit

(Continued on next slide)

Ref. Page 33 Chapter 03: Number Systems Slide 32/43


Computer Fundamentals : Pradeep K. Sinha & Priti Sinha
Shortcut Method for Converting a Binary
Number to its Equivalent Hexadecimal Number

Example

1111012 = ?16

Step 1: Divide the binary digits into groups of four


starting from the right

0011 1101

Step 2: Convert each group into a hexadecimal digit


00112 = 0 x 23 + 0 x 22 + 1 x 21 + 1 x 20 = 310 = 316
11012 = 1 x 23 + 1 x 22 + 0 x 21 + 1 x 20 = 310 = D16

Hence, 1111012 = 3D16

Ref. Page 33 Chapter 03: Number Systems Slide 33/43


Computer Fundamentals : Pradeep K. Sinha & Priti Sinha
Shortcut Method for Converting a Hexadecimal
Number to its Equivalent Binary Number

Method

Step 1: Convert the decimal equivalent of each


hexadecimal digit to a 4 digit binary
number

Step 2: Combine all the resulting binary groups


(of 4 digits each) in a single binary number

(Continued on next slide)

Ref. Page 34 Chapter 03: Number Systems Slide 34/43


Computer Fundamentals : Pradeep K. Sinha & Priti Sinha
Shortcut Method for Converting a Hexadecimal
Number to its Equivalent Binary Number

Example

2AB16 = ?2

Step 1: Convert each hexadecimal digit to a 4 digit


binary number

216 = 210 = 00102


A16 = 1010 = 10102
B16 = 1110 = 10112

Ref. Page 34 Chapter 03: Number Systems Slide 35/43


Computer Fundamentals : Pradeep K. Sinha & Priti Sinha
Shortcut Method for Converting a Hexadecimal
Number to its Equivalent Binary Number

Step 2: Combine the binary groups


2AB16 = 0010 1010 1011
2 A B

Hence, 2AB16 = 0010101010112

Ref. Page 34 Chapter 03: Number Systems Slide 36/43


Computer Fundamentals : Pradeep K. Sinha & Priti Sinha

Fractional Numbers

Chapter 03: Number Systems Slide 37/43


Computer Fundamentals : Pradeep K. Sinha & Priti Sinha

Fractional Numbers
Fractional numbers are formed same way as decimal
number system
In general, a number in a number system with base b
would be written as:
an an-1… a0 . a-1 a-2 … a-m

And would be interpreted to mean:


an x bn + an-1 x bn-1 + … + a0 x b0 + a-1 x b-1 + a-2 x b-2 +
… + a-m x b-m

The symbols an, an-1, …, a-m in above representation


should be one of the b symbols allowed in the number
system

Ref. Page 35 Chapter 03: Number Systems Slide 38/43


Computer Fundamentals : Pradeep K. Sinha & Priti Sinha
Formation of Fractional Numbers in
Binary Number System (Example)

Binary Point

Position 4 3 2 1 0 . -1 -2 -3 -4

Position Value 24 23 22 21 20 2-1 2-2 2-3 2-4

Quantity 16 8 4 2 1 1/
2
1/
4
1/
8
1/
16
Represented

(Continued on next slide)

Ref. Page 35 Chapter 03: Number Systems Slide 39/43


Computer Fundamentals : Pradeep K. Sinha & Priti Sinha
Formation of Fractional Numbers in
Binary Number System (Example)

Example

110.1012 = 1 x 22 + 1 x 21 + 0 x 20 + 1 x 2-1 + 0 x 2-2 + 1 x 2-3


= 4 + 2 + 0 + 0.5 + 0 + 0.125
= 6.62510

Ref. Page 36 Chapter 03: Number Systems Slide 40/43


Computer Fundamentals : Pradeep K. Sinha & Priti Sinha
Formation of Fractional Numbers in
Octal Number System (Example)

Octal Point

Position 3 2 1 0 . -1 -2 -3

Position Value 83 82 81 80 8-1 8-2 8-3

Quantity 512 64 8 1 1/
8
1/
64
1/
512
Represented

(Continued on next slide)

Ref. Page 35 Chapter 03: Number Systems Slide 41/43


Computer Fundamentals : Pradeep K. Sinha & Priti Sinha
Formation of Fractional Numbers in
Octal Number System (Example)

Example

127.548 = 1 x 82 + 2 x 81 + 7 x 80 + 5 x 8-1 + 4 x 8-2


= 64 + 16 + 7 + 5/8 + 4/64
= 87 + 0.625 + 0.0625
= 87.687510

Ref. Page 36 Chapter 03: Number Systems Slide 42/43


Computer Fundamentals : Pradeep K. Sinha & Priti Sinha

Key Words/Phrases

 Base  Least Significant Digit (LSD)


 Binary number system  Memory dump
 Binary point  Most Significant Digit (MSD)
 Bit  Non-positional number
 Decimal number system system
 Division-Remainder technique  Number system
 Fractional numbers  Octal number system
 Hexadecimal number system  Positional number system

Chapter 03: Number Systems Slide 43/43


Computer Fundamentals : Pradeep K. Sinha & Priti Sinha

Computer Fundamentals

Pradeep K. Sinha
Priti Sinha

Chapter 4

Computer Codes
Chapter 04: Computer Codes Slide 1/36
Computer Fundamentals : Pradeep K. Sinha & Priti Sinha

Learning Objectives

In this chapter you will learn about:

 Computer data
 Computer codes: representation of data in binary
 Most commonly used computer codes
 Collating sequence

Chapter 04: Computer Codes Slide 2/36


Computer Fundamentals : Pradeep K. Sinha & Priti Sinha

Data Types and Their


Binary Representation

Chapter 04: Computer Codes Slide 3/36


Computer Fundamentals : Pradeep K. Sinha & Priti Sinha

Data Types

 Numeric Data consists of only numbers 0, 1, 2, …, 9


 Alphabetic Data consists of only the letters A, B, C,
…, Z, in both uppercase and lowercase, and blank
character
 Alphanumeric Data is a string of symbols where a
symbol may be one of the letters A, B, C, …, Z, in
either uppercase or lowercase, or one of the digits 0,
1, 2, …, 9, or a special character, such as + - * / , . (
) = etc.

Ref. Page 38 Chapter 04: Computer Codes Slide 4/36


Computer Fundamentals : Pradeep K. Sinha & Priti Sinha

Computer Codes
 Computer codes are used for internal representation of
data in computers
 As computers use binary numbers for internal data
representation, computer codes use binary coding
schemes
 In binary coding, every symbol that appears in the data
is represented by a group of bits
 The group of bits used to represent a symbol is called a
byte

(Continued on next slide)

Ref. Page 38 Chapter 04: Computer Codes Slide 5/36


Computer Fundamentals : Pradeep K. Sinha & Priti Sinha

Computer Codes

 As most modern coding schemes use 8 bits to represent


a symbol, the term byte is often used to mean a group
of 8 bits
 Commonly used computer codes are BCD, EBCDIC, and
ASCII

Ref. Page 38 Chapter 04: Computer Codes Slide 6/36


Computer Fundamentals : Pradeep K. Sinha & Priti Sinha

BCD

Chapter 04: Computer Codes Slide 7/36


Computer Fundamentals : Pradeep K. Sinha & Priti Sinha

BCD

 BCD stands for Binary Coded Decimal


 It is one of the early computer codes
 It uses 6 bits to represent a symbol
 It can represent 64 (26) different characters

Ref. Page 39 Chapter 04: Computer Codes Slide 8/36


Computer Fundamentals : Pradeep K. Sinha & Priti Sinha
Coding of Alphabetic and Numeric
Characters in BCD
BCD Code BCD Code
Char Octal Char Octal
Zone Digit Zone Digit
A 11 0001 61 N 10 0101 45
B 11 0010 62 O 10 0110 46
C 11 0011 63 P 10 0111 47
D 11 0100 64 Q 10 1000 50
E 11 0101 65 R 10 1001 51
F 11 0110 66 S 01 0010 22
G 11 0111 67 T 01 0011 23
H 11 1000 70 U 01 0100 24
I 11 1001 71 V 01 0101 25
J 10 0001 41 W 01 0110 26
K 10 0010 42 X 01 0111 27
L 10 0011 43 Y 01 1000 30
M 10 0100 44 Z 01 1001 31
(Continued on next slide)

Ref. Page 40 Chapter 04: Computer Codes Slide 9/36


Computer Fundamentals : Pradeep K. Sinha & Priti Sinha
Coding of Alphabetic and Numeric
Characters in BCD

BCD Code Octal


Character
Zone Digit Equivalent
1 00 0001 01
2 00 0010 02
3 00 0011 03
4 00 0100 04
5 00 0101 05
6 00 0110 06
7 00 0111 07
8 00 1000 10
9 00 1001 11
0 00 0000 00

Ref. Page 40 Chapter 04: Computer Codes Slide 10/36


Computer Fundamentals : Pradeep K. Sinha & Priti Sinha

BCD Coding Scheme (Example 1)


Example
Show the binary digits used to record the word BASE in BCD

Solution:
B= 110010 in BCD binary notation
A= 110001 in BCD binary notation
S= 010010 in BCD binary notation
E= 110101 in BCD binary notation

So the binary digits

110010 110001 010010 110101


B A S E

will record the word BASE in BCD

Ref. Page 40 Chapter 04: Computer Codes Slide 11/36


Computer Fundamentals : Pradeep K. Sinha & Priti Sinha

BCD Coding Scheme (Example 2)


Example

Using octal notation, show BCD coding for the word DIGIT

Solution:
D = 64 in BCD octal notation
I = 71 in BCD octal notation
G = 67 in BCD octal notation
I = 71 in BCD octal notation
T = 23 in BCD octal notation

Hence, BCD coding for the word DIGIT in octal notation will be

64 71 67 71 23
D I G I T

Ref. Page 40 Chapter 04: Computer Codes Slide 12/36


Computer Fundamentals : Pradeep K. Sinha & Priti Sinha

EBCDIC

Chapter 04: Computer Codes Slide 13/36


Computer Fundamentals : Pradeep K. Sinha & Priti Sinha

EBCDIC

 EBCDIC stands for Extended Binary Coded Decimal


Interchange Code
 It uses 8 bits to represent a symbol
 It can represent 256 (28) different characters

Ref. Page 40 Chapter 04: Computer Codes Slide 14/36


Computer Fundamentals : Pradeep K. Sinha & Priti Sinha
Coding of Alphabetic and Numeric
Characters in EBCDIC
EBCDIC Code
Char Hex EBCDIC Code
Digit Zone Char Hex
Digit Zone
A 1100 0001 C1
N 1101 0101 D5
B 1100 0010 C2
O 1101 0110 D6
C 1100 0011 C3
P 1101 0111 D7
D 1100 0100 C4
Q 1101 1000 D8
E 1100 0101 C5 R 1101 1001 D9
F 1100 0110 C6 S 1110 0010 E2
G 1100 0111 C7 T 1110 0011 E3
H 1100 1000 C8 U 1110 0100 E4
I 1100 1001 C9 V 1110 0101 E5
J 1101 0001 D1 W 1110 0110 E6
K 1101 0010 D2 X 1110 0111 E7
L 1101 0011 D3 Y 1110 1000 E8

M 1101 0100 D4 Z 1110 1001 E9

(Continued on next slide)

Ref. Page 41 Chapter 04: Computer Codes Slide 15/36


Computer Fundamentals : Pradeep K. Sinha & Priti Sinha
Coding of Alphabetic and Numeric
Characters in EBCDIC

EBCDIC Code Hexadecimal


Character
Digit Zone Equivalent
0 1111 0000 F0
1 1111 0001 F1
2 1111 0010 F2
3 1111 0011 F3
4 1111 0100 F4
5 1111 0101 F5
6 1111 0110 F6
7 1111 0111 F7
8 1111 1000 F8
9 1111 1001 F9

Ref. Page 41 Chapter 04: Computer Codes Slide 16/36


Computer Fundamentals : Pradeep K. Sinha & Priti Sinha

Zoned Decimal Numbers

 Zoned decimal numbers are used to represent numeric


values (positive, negative, or unsigned) in EBCDIC
 A sign indicator (C for plus, D for minus, and F for
unsigned) is used in the zone position of the rightmost
digit
 Zones for all other digits remain as F, the zone value for
numeric characters in EBCDIC
 In zoned format, there is only one digit per byte

Ref. Page 41 Chapter 04: Computer Codes Slide 17/36


Computer Fundamentals : Pradeep K. Sinha & Priti Sinha

Examples Zoned Decimal Numbers

Numeric Value EBCDIC Sign Indicator

345 F3F4F5 F for unsigned

+345 F3F4C5 C for positive

-345 F3F4D5 D for negative

Ref. Page 42 Chapter 04: Computer Codes Slide 18/36


Computer Fundamentals : Pradeep K. Sinha & Priti Sinha

Packed Decimal Numbers


 Packed decimal numbers are formed from zoned decimal
numbers in the following manner:

Step 1: The zone half and the digit half of


the rightmost byte are reversed

Step 2: All remaining zones are dropped out

 Packed decimal format requires fewer number of bytes


than zoned decimal format for representing a number

 Numbers represented in packed decimal format can be


used for arithmetic operations

Ref. Page 42 Chapter 04: Computer Codes Slide 19/36


Computer Fundamentals : Pradeep K. Sinha & Priti Sinha
Examples of Conversion of Zoned
Decimal Numbers to Packed Decimal Format

Numeric Value EBCDIC Sign Indicator


345 F3F4F5 345F
+345 F3F4C5 345C
-345 F3F4D5 345D
3456 F3F4F5F6 03456F

Ref. Page 42 Chapter 04: Computer Codes Slide 20/36


Computer Fundamentals : Pradeep K. Sinha & Priti Sinha

EBCDIC Coding Scheme


Example

Using binary notation, write EBCDIC coding for the word BIT. How
many bytes are required for this representation?

Solution:
B = 1100 0010 in EBCDIC binary notation
I = 1100 1001 in EBCDIC binary notation
T = 1110 0011 in EBCDIC binary notation

Hence, EBCDIC coding for the word BIT in binary notation will be

11000010 11001001 11100011


B I T

3 bytes will be required for this representation because each letter


requires 1 byte (or 8 bits)

Ref. Page 42 Chapter 04: Computer Codes Slide 21/36


Computer Fundamentals : Pradeep K. Sinha & Priti Sinha

ASCII

Chapter 04: Computer Codes Slide 22/36


Computer Fundamentals : Pradeep K. Sinha & Priti Sinha

ASCII

 ASCII stands for American Standard Code for


Information Interchange.

 ASCII is of two types – ASCII-7 and ASCII-8

 ASCII-7 uses 7 bits to represent a symbol and can


represent 128 (27) different characters

 ASCII-8 uses 8 bits to represent a symbol and can


represent 256 (28) different characters

 First 128 characters in ASCII-7 and ASCII-8 are same

Ref. Page 43 Chapter 04: Computer Codes Slide 23/36


Computer Fundamentals : Pradeep K. Sinha & Priti Sinha
Coding of Numeric and
Alphabetic Characters in ASCII

ASCII-7 / ASCII-8 Hexadecimal


Character
Zone Digit Equivalent
0 0011 0000 30
1 0011 0001 31
2 0011 0010 32
3 0011 0011 33
4 0011 0100 34
5 0011 0101 35
6 0011 0110 36
7 0011 0111 37
8 0011 1000 38
9 0011 1001 39

(Continued on next slide)

Ref. Page 44 Chapter 04: Computer Codes Slide 24/36


Computer Fundamentals : Pradeep K. Sinha & Priti Sinha
Coding of Numeric and
Alphabetic Characters in ASCII
ASCII-7 / ASCII-8 Hexadecimal
Character
Zone Digit Equivalent

A 0100 0001 41
B 0100 0010 42
C 0100 0011 43
D 0100 0100 44
E 0100 0101 45
F 0100 0110 46
G 0100 0111 47
H 0100 1000 48
I 0100 1001 49
J 0100 1010 4A
K 0100 1011 4B
L 0100 1100 4C
M 0100 1101 4D
(Continued on next slide)

Ref. Page 44 Chapter 04: Computer Codes Slide 25/36


Computer Fundamentals : Pradeep K. Sinha & Priti Sinha
Coding of Numeric and
Alphabetic Characters in ASCII

ASCII-7 / ASCII-8 Hexadecimal


Character
Zone Digit Equivalent
N 0100 1110 4E
O 0100 1111 4F
P 0101 0000 50
Q 0101 0001 51
R 0101 0010 52
S 0101 0011 53
T 0101 0100 54
U 0101 0101 55
V 0101 0110 56
W 0101 0111 57
X 0101 1000 58
Y 0101 1001 59
Z 0101 1010 5A

Ref. Page 44 Chapter 04: Computer Codes Slide 26/36


Computer Fundamentals : Pradeep K. Sinha & Priti Sinha

ASCII-7 Coding Scheme


Example

Write binary coding for the word BOY in ASCII-7. How many bytes are required
for this representation?

Solution:

B = 1000010 in ASCII-7 binary notation


O = 1001111 in ASCII-7 binary notation
Y = 1011001 in ASCII-7 binary notation

Hence, binary coding for the word BOY in ASCII-7 will be

1000010 1001111 1011001


B O Y

Since each character in ASCII-7 requires one byte for its representation and
there are 3 characters in the word BOY, 3 bytes will be required for this
representation

Ref. Page 45 Chapter 04: Computer Codes Slide 27/36


Computer Fundamentals : Pradeep K. Sinha & Priti Sinha

ASCII-8 Coding Scheme


Example

Write binary coding for the word SKY in ASCII-8. How many bytes are
required for this representation?

Solution:

S = 01010011 in ASCII-8 binary notation


K = 01001011 in ASCII-8 binary notation
Y = 01011001 in ASCII-8 binary notation

Hence, binary coding for the word SKY in ASCII-8 will be

01010011 01001011 01011001


S K Y

Since each character in ASCII-8 requires one byte for its representation
and there are 3 characters in the word SKY, 3 bytes will be required for
this representation

Ref. Page 45 Chapter 04: Computer Codes Slide 28/36


Computer Fundamentals : Pradeep K. Sinha & Priti Sinha

Unicode

Chapter 04: Computer Codes Slide 29/36


Computer Fundamentals : Pradeep K. Sinha & Priti Sinha

Unicode
 Why Unicode:
 No single encoding system supports all languages
 Different encoding systems conflict

 Unicode features:
 Provides a consistent way of encoding multilingual
plain text
 Defines codes for characters used in all major
languages of the world
 Defines codes for special characters, mathematical
symbols, technical symbols, and diacritics

Ref. Page 46 Chapter 04: Computer Codes Slide 30/36


Computer Fundamentals : Pradeep K. Sinha & Priti Sinha

Unicode
 Unicode features (continued):
 Capacity to encode as many as a million characters
 Assigns each character a unique numeric value and
name
 Reserves a part of the code space for private use
 Affords simplicity and consistency of ASCII, even
corresponding characters have same code
 Specifies an algorithm for the presentation of text
with bi-directional behavior
 Encoding Forms
 UTF-8, UTF-16, UTF-32

Ref. Page 46 Chapter 04: Computer Codes Slide 31/36


Computer Fundamentals : Pradeep K. Sinha & Priti Sinha

Collating Sequence

Chapter 04: Computer Codes Slide 32/36


Computer Fundamentals : Pradeep K. Sinha & Priti Sinha

Collating Sequence
 Collating sequence defines the assigned ordering
among the characters used by a computer

 Collating sequence may vary, depending on the type


of computer code used by a particular computer

 In most computers, collating sequences follow the


following rules:

1. Letters are considered in alphabetic order


(A < B < C … < Z)

2. Digits are considered in numeric order


(0 < 1 < 2 … < 9)

Ref. Page 48 Chapter 04: Computer Codes Slide 33/36


Computer Fundamentals : Pradeep K. Sinha & Priti Sinha

Sorting in EBCDIC
Example

Suppose a computer uses EBCDIC as its internal


representation of characters. In which order will this
computer sort the strings 23, A1, 1A?

Solution:

In EBCDIC, numeric characters are treated to be greater


than alphabetic characters. Hence, in the said computer,
numeric characters will be placed after alphabetic
characters and the given string will be treated as:

A1 < 1A < 23

Therefore, the sorted sequence will be: A1, 1A, 23.

Ref. Page 48 Chapter 04: Computer Codes Slide 34/36


Computer Fundamentals : Pradeep K. Sinha & Priti Sinha

Sorting in ASCII
Example

Suppose a computer uses ASCII for its internal representation of


characters. In which order will this computer sort the strings 23, A1,
1A, a2, 2a, aA, and Aa?

Solution:

In ASCII, numeric characters are treated to be less than alphabetic


characters. Hence, in the said computer, numeric characters will be
placed before alphabetic characters and the given string will be
treated as:

1A < 23 < 2a < A1 < Aa < a2 < aA

Therefore, the sorted sequence will be: 1A, 23, 2a, A1, Aa, a2, and
aA

Ref. Page 49 Chapter 04: Computer Codes Slide 35/36


Computer Fundamentals : Pradeep K. Sinha & Priti Sinha

Key Words/Phrases
 Alphabetic data
 Alphanumeric data
 American Standard Code for Information Interchange (ASCII)
 Binary Coded Decimal (BCD) code
 Byte
 Collating sequence
 Computer codes
 Control characters
 Extended Binary-Coded Decimal Interchange Code (EBCDIC)
 Hexadecimal equivalent
 Numeric data
 Octal equivalent
 Packed decimal numbers
 Unicode
 Zoned decimal numbers

Chapter 04: Computer Codes Slide 36/36


Computer Fundamentals : Pradeep K. Sinha & Priti Sinha

Computer Fundamentals

Pradeep K. Sinha
Priti Sinha

Chapter 5

Computer
Arithmetic
Chapter 05: Computer Arithmetic Slide 1/31
Computer Fundamentals : Pradeep K. Sinha & Priti Sinha

Learning Objectives
In this chapter you will learn about:

 Reasons for using binary instead of decimal


numbers
 Basic arithmetic operations using binary numbers
 Addition (+)
 Subtraction (-)
 Multiplication (*)
 Division (/)

Chapter 05: Computer Arithmetic Slide 2/31


Computer Fundamentals : Pradeep K. Sinha & Priti Sinha

Why Binary?

Chapter 05: Computer Arithmetic Slide 3/31


Computer Fundamentals : Pradeep K. Sinha & Priti Sinha

Binary over Decimal


 Information is handled in a computer by electronic/
electrical components
 Electronic components operate in binary mode (can
only indicate two states – on (1) or off (0)
 Binary number system has only two digits (0 and 1),
and is suitable for expressing two possible states
 In binary system, computer circuits only have to handle
two binary digits rather than ten decimal digits causing:
 Simpler internal circuit design
 Less expensive
 More reliable circuits
 Arithmetic rules/processes possible with binary
numbers

Ref. Page 51 Chapter 05: Computer Arithmetic Slide 4/31


Computer Fundamentals : Pradeep K. Sinha & Priti Sinha
Examples of a Few Devices that work in
Binary Mode

Binary On (1) Off (0)


State

Bulb

Switch

Circuit
Pulse

Ref. Page 52 Chapter 05: Computer Arithmetic Slide 5/31


Computer Fundamentals : Pradeep K. Sinha & Priti Sinha

Binary Arithmetic

Chapter 05: Computer Arithmetic Slide 6/31


Computer Fundamentals : Pradeep K. Sinha & Priti Sinha

Binary Arithmetic

 Binary arithmetic is simple to learn as binary number


system has only two digits – 0 and 1

 Following slides show rules and example for the four


basic arithmetic operations using binary numbers

Ref. Page 52 Chapter 05: Computer Arithmetic Slide 7/31


Computer Fundamentals : Pradeep K. Sinha & Priti Sinha

Binary Addition

Rule for binary addition is as follows:

0 + 0 = 0
0 + 1 = 1
1 + 0 = 1
1 + 1 = 0 plus a carry of 1 to next higher column

Ref. Page 52 Chapter 05: Computer Arithmetic Slide 8/31


Computer Fundamentals : Pradeep K. Sinha & Priti Sinha

Binary Addition (Example 1)


Example
Add binary numbers 10011 and 1001 in both decimal and
binary form

Solution

Binary Decimal

carry 11 carry 1
10011 19
+1001 +9

11100 28

In this example, carry are generated for first and second columns

Ref. Page 53 Chapter 05: Computer Arithmetic Slide 9/31


Computer Fundamentals : Pradeep K. Sinha & Priti Sinha

Binary Addition (Example 2)


Example

Add binary numbers 100111 and 11011 in both decimal


and binary form

Solution
The addition of three 1s
Binary Decimal can be broken up into two
steps. First, we add only
carry 11111 carry 1 two 1s giving 10 (1 + 1 =
100111 39 10). The third 1 is now
added to this result to
+11011 +27 obtain 11 (a 1 sum with a 1
carry). Hence, 1 + 1 + 1 =
1000010 66 1, plus a carry of 1 to next
higher column.

Ref. Page 53 Chapter 05: Computer Arithmetic Slide 10/31


Computer Fundamentals : Pradeep K. Sinha & Priti Sinha

Binary Subtraction

Rule for binary subtraction is as follows:

0 - 0 = 0
0 - 1 = 1 with a borrow from the next column
1 - 0 = 1
1 - 1 = 0

Ref. Page 53 Chapter 05: Computer Arithmetic Slide 11/31


Computer Fundamentals : Pradeep K. Sinha & Priti Sinha

Binary Subtraction (Example)


Example

Subtract 011102 from 101012

Solution

12
0202
10101
-01110

00111

Note: Go through explanation given in the book

Ref. Page 54 Chapter 05: Computer Arithmetic Slide 12/31


Computer Fundamentals : Pradeep K. Sinha & Priti Sinha

Complement of a Number

Number of digits
in the number

C = Bn - 1 - N

Complement Base of the The number


of the number number

Ref. Page 54 Chapter 05: Computer Arithmetic Slide 13/31


Computer Fundamentals : Pradeep K. Sinha & Priti Sinha

Complement of a Number (Example 1)

Example

Find the complement of 3710

Solution

Since the number has 2 digits and the value of


base is 10,
(Base)n - 1 = 102 - 1 = 99
Now 99 - 37 = 62

Hence, complement of 3710 = 6210

Ref. Page 55 Chapter 05: Computer Arithmetic Slide 14/31


Computer Fundamentals : Pradeep K. Sinha & Priti Sinha

Complement of a Number (Example 2)

Example
Find the complement of 68

Solution
Since the number has 1 digit and the value of
base is 8,
(Base)n - 1 = 81 - 1 = 710 = 78
Now 78 - 68 = 18

Hence, complement of 68 = 18

Ref. Page 55 Chapter 05: Computer Arithmetic Slide 15/31


Computer Fundamentals : Pradeep K. Sinha & Priti Sinha

Complement of a Binary Number

Complement of a binary number can be obtained by


transforming all its 0’s to 1’s and all its 1’s to 0’s

Example
Complement of 1 0 1 1 0 1 0 is

0 1 0 0 1 0 1

Note: Verify by conventional complement

Ref. Page 55 Chapter 05: Computer Arithmetic Slide 16/31


Computer Fundamentals : Pradeep K. Sinha & Priti Sinha

Complementary Method of Subtraction

Involves following 3 steps:

Step 1: Find the complement of the number you


are subtracting (subtrahend)

Step 2: Add this to the number from which you


are taking away (minuend)

Step 3: If there is a carry of 1, add it to obtain


the result; if there is no carry, recomplement the
sum and attach a negative sign

Complementary subtraction is an additive approach of subtraction

Ref. Page 55 Chapter 05: Computer Arithmetic Slide 17/31


Computer Fundamentals : Pradeep K. Sinha & Priti Sinha

Complementary Subtraction (Example 1)

Example:
Subtract 5610 from 9210 using complementary method.

Solution
Step 1: Complement of 5610
= 102 - 1 - 56 = 99 – 56 = 4310 The result may be
verified using the
Step 2: 92 + 43 (complement of 56) method of normal
= 135 (note 1 as carry) subtraction:

Step 3: 35 + 1 (add 1 carry to sum) 92 - 56 = 36

Result = 36

Ref. Page 56 Chapter 05: Computer Arithmetic Slide 18/31


Computer Fundamentals : Pradeep K. Sinha & Priti Sinha

Complementary Subtraction (Example 2)

Example
Subtract 3510 from 1810 using complementary method.
Solution

Step 1: Complement of 3510 Step 3: Since there is no carry,


= 102 - 1 - 35 re-complement the sum and
= 99 - 35 attach a negative sign to
obtain the result.
= 6410
Result = -(99 - 82)
Step 2: 18 = -17
+ 64 (complement
of 35) The result may be verified using normal
82 subtraction:

18 - 35 = -17

Ref. Page 56 Chapter 05: Computer Arithmetic Slide 19/31


Computer Fundamentals : Pradeep K. Sinha & Priti Sinha
Binary Subtraction Using Complementary
Method (Example 1)
Example
Subtract 01110002 (5610) from 10111002 (9210) using
complementary method.

Solution
1011100
+1000111 (complement of 0111000)

10100011

1 (add the carry of 1)

0100100

Result = 01001002 = 3610

Ref. Page 56 Chapter 05: Computer Arithmetic Slide 20/31


Computer Fundamentals : Pradeep K. Sinha & Priti Sinha
Binary Subtraction Using Complementary
Method (Example 2)
Example
Subtract 1000112 (3510) from 0100102 (1810) using
complementary method.

Solution
010010
+011100 (complement of 100011)

101110

Since there is no carry, we have to complement the sum and


attach a negative sign to it. Hence,

Result = -0100012 (complement of 1011102)


= -1710

Ref. Page 56 Chapter 05: Computer Arithmetic Slide 21/31


Computer Fundamentals : Pradeep K. Sinha & Priti Sinha

Binary Multiplication

Table for binary multiplication is as follows:

0x0=0
0x1=0
1x0=0
1x1=1

Ref. Page 57 Chapter 05: Computer Arithmetic Slide 22/31


Computer Fundamentals : Pradeep K. Sinha & Priti Sinha

Binary Multiplication (Example 1)


Example

Multiply the binary numbers 1010 and 1001

Solution
1010 Multiplicand
x1001 Multiplier

1010 Partial Product


0000 Partial Product
0000 Partial Product
1010 Partial Product

1011010 Final Product


(Continued on next slide)

Ref. Page 57 Chapter 05: Computer Arithmetic Slide 23/31


Computer Fundamentals : Pradeep K. Sinha & Priti Sinha

Binary Multiplication (Example 2)


Whenever a 0 appears in the multiplier, a separate partial
product consisting of a string of zeros need not be generated
(only a shift will do). Hence,

1010
x1001

1010
1010SS (S = left shift)

1011010

Ref. Page 58 Chapter 05: Computer Arithmetic Slide 24/31


Computer Fundamentals : Pradeep K. Sinha & Priti Sinha

Binary Division
Table for binary division is as follows:

0  0 = Divide by zero error


0  1 = 0
1  0 = Divide by zero error
1  1 = 1

As in the decimal number system (or in any other number


system), division by zero is meaningless

The computer deals with this problem by raising an error


condition called ‘Divide by zero’ error

Ref. Page 59 Chapter 05: Computer Arithmetic Slide 25/31


Computer Fundamentals : Pradeep K. Sinha & Priti Sinha

Rules for Binary Division


1. Start from the left of the dividend
2. Perform a series of subtractions in which the divisor is
subtracted from the dividend
3. If subtraction is possible, put a 1 in the quotient and
subtract the divisor from the corresponding digits of
dividend
4. If subtraction is not possible (divisor greater than
remainder), record a 0 in the quotient
5. Bring down the next digit to add to the remainder
digits. Proceed as before in a manner similar to long
division

Ref. Page 59 Chapter 05: Computer Arithmetic Slide 26/31


Computer Fundamentals : Pradeep K. Sinha & Priti Sinha

Binary Division (Example 1)


Example

Divide 1000012 by 1102

Solution 0101 (Quotient)

110 100001 (Dividend)


110 1 Divisor greater than 100, so put 0 in quotient
1000 2 Add digit from dividend to group used above
110 3 Subtraction possible, so put 1 in quotient
100 4 Remainder from subtraction plus digit from dividend
110 5 Divisor greater, so put 0 in quotient
1001 6 Add digit from dividend to group
110 7 Subtraction possible, so put 1 in quotient
11 Remainder

Ref. Page 60 Chapter 05: Computer Arithmetic Slide 27/31


Computer Fundamentals : Pradeep K. Sinha & Priti Sinha
Additive Method of Multiplication
and Division

Most computers use the additive method for performing


multiplication and division operations because it simplifies
the internal circuit design of computer systems

Example
4 x 8 = 8 + 8 + 8 + 8 = 32

Ref. Page 60 Chapter 05: Computer Arithmetic Slide 28/31


Computer Fundamentals : Pradeep K. Sinha & Priti Sinha

Rules for Additive Method of Division


 Subtract the divisor repeatedly from the dividend until
the result of subtraction becomes less than or equal to
zero
 If result of subtraction is zero, then:
 quotient = total number of times subtraction was
performed
 remainder = 0
 If result of subtraction is less than zero, then:
 quotient = total number of times subtraction was
performed minus 1
 remainder = result of the subtraction previous to
the last subtraction

Ref. Page 60 Chapter 05: Computer Arithmetic Slide 29/31


Computer Fundamentals : Pradeep K. Sinha & Priti Sinha

Additive Method of Division (Example)

Example
Divide 3310 by 610 using the method of addition

Solution:
33 - 6 = 27
27 - 6 = 21 Since the result of the last
21 - 6 = 15 subtraction is less than zero,
15 - 6 = 9
9-6= 3 Quotient = 6 - 1 (ignore last
3 - 6 = -3 subtraction) = 5

Total subtractions = 6 Remainder = 3 (result of previous


subtraction)

Ref. Page 60 Chapter 05: Computer Arithmetic Slide 30/31


Computer Fundamentals : Pradeep K. Sinha & Priti Sinha

Key Words/Phrases
 Additive method of division
 Additive method of multiplication
 Additive method of subtraction
 Binary addition
 Binary arithmetic
 Binary division
 Binary multiplication
 Binary subtraction
 Complement
 Complementary subtraction
 Computer arithmetic

Chapter 05: Computer Arithmetic Slide 31/31


Computer Fundamentals : Pradeep K. Sinha & Priti Sinha

Computer Fundamentals

Pradeep K. Sinha
Priti Sinha

Chapter 6

Boolean Algebra
and Logic Circuits
Chapter 06: Boolean Algebra and Logic Circuits Slide 1/86
Computer Fundamentals : Pradeep K. Sinha & Priti Sinha

Learning Objectives

In this chapter you will learn about:

 Boolean algebra
 Fundamental concepts and basic laws of Boolean
algebra
 Boolean function and minimization
 Logic gates
 Logic circuits and Boolean expressions
 Combinational circuits and their design

Chapter 06: Boolean Algebra and Logic Circuits Slide 2/86


Computer Fundamentals : Pradeep K. Sinha & Priti Sinha

Boolean Algebra

Chapter 06: Boolean Algebra and Logic Circuits Slide 3/86


Computer Fundamentals : Pradeep K. Sinha & Priti Sinha

Boolean Algebra

 An algebra that deals with binary number system


 George Boole (1815-1864), an English mathematician,
developed it for:
 Simplifying representation
 Manipulation of propositional logic
 In 1938, Claude E. Shannon proposed using Boolean
algebra in design of relay switching circuits
 Provides economical and straightforward approach
 Used extensively in designing electronic circuits used in
computers

Ref. Page 63 Chapter 06: Boolean Algebra and Logic Circuits Slide 4/86
Computer Fundamentals : Pradeep K. Sinha & Priti Sinha

Fundamental Concepts of Boolean Algebra

 Use of binary digit


 Variables used in Boolean equations can have either of
two possible values, 0 or 1
 Logical addition
 Symbol ‘+’, also known as ‘OR’ operator, is used for
logical addition. It follows law of binary addition
 Logical multiplication
 Symbol ‘.’, also known as ‘AND’ operator, is used for
logical multiplication. It follows law of binary
multiplication
 Complementation
 Symbol ‘-’, also known as ‘NOT’ operator, is used for
complementation. It follows law of binary complement

Ref. Page 64 Chapter 06: Boolean Algebra and Logic Circuits Slide 5/86
Computer Fundamentals : Pradeep K. Sinha & Priti Sinha

Truth Tables for Boolean Operators

Inputs Output Inputs Output


Input Output

A  B = C A  B = C
0 0 0 0 0 0 A A
0 1 1 0 1 0
0 1
1 0 1 1 0 0
1 1 1 1 1 1 1 0

Truth Table for OR (+) Truth Table for AND (.) Truth Table for NOT (-)

Ref. Page 64 Chapter 06: Boolean Algebra and Logic Circuits Slide 6/86
Computer Fundamentals : Pradeep K. Sinha & Priti Sinha

Operator Precedence

 Each operator has a precedence level


 Higher the operator’s precedence level, earlier it is evaluated
 Expression is scanned from left to right
 First, expressions enclosed within parentheses are evaluated
 Then, all complement (NOT) operations are performed
 Then, all ‘’ (AND) operations are performed
 Finally, all ‘’ (OR) operations are performed

(Continued on next slide)

Ref. Page 65 Chapter 06: Boolean Algebra and Logic Circuits Slide 7/86
Computer Fundamentals : Pradeep K. Sinha & Priti Sinha

Operator Precedence

XYZ

1st 2nd 3rd

Ref. Page 65 Chapter 06: Boolean Algebra and Logic Circuits Slide 8/86
Computer Fundamentals : Pradeep K. Sinha & Priti Sinha

Postulates of Boolean Algebra


Postulate 1:
(a) A = 0, if and only if, A is not equal to 1
(b) A = 1, if and only if, A is not equal to 0

Postulate 2:
(a) x  0 = x
(b) x  1 = x

Postulate 3: Commutative Law


(a) x  y = y  x
(b) x  y = y  x

(Continued on next slide)

Ref. Page 65 Chapter 06: Boolean Algebra and Logic Circuits Slide 9/86
Computer Fundamentals : Pradeep K. Sinha & Priti Sinha

Postulates of Boolean Algebra


Postulate 4: Associative Law
(a) x  (y  z) = (x  y)  z
(b) x  (y  z) = (x  y)  z

Postulate 5: Distributive Law


(a) x  (y  z) = (x  y)  (x  z)
(b) x  (y  z) = (x  y)  (x  z)

Postulate 6:
(a) x  x = 1
(b) x  x = 0

Ref. Page 65 Chapter 06: Boolean Algebra and Logic Circuits Slide 10/86
Computer Fundamentals : Pradeep K. Sinha & Priti Sinha

The Principle of Duality


There is a precise duality between the operators . (AND) and +
(OR), and the digits 0 and 1.

For example, in the table below, the second row is obtained from
the first row and vice versa simply by interchanging ‘+’ with ‘.’
and ‘0’ with ‘1’

Column 1 Column 2 Column 3


Row 1 11=1 1+0=01=1 00=0
Row 2 00=0 01=10=0 11=1

Therefore, if a particular theorem is proved, its dual theorem


automatically holds and need not be proved separately

Ref. Page 66 Chapter 06: Boolean Algebra and Logic Circuits Slide 11/86
Computer Fundamentals : Pradeep K. Sinha & Priti Sinha
Some Important Theorems of
Boolean Algebra

Sr. Theorems/ Dual Theorems/ Name


No. Identities Identities (if any)

1 x+x=x xx=x Idempotent Law

2 x+1=1 x0=0

3 x+xy=x x  (x + y) = x Absorption Law

4 x =x Involution Law

5 x  (x + y ) = x  y x +x  y = x + y

6 xy = x  y xy = x + y De Morgan’s Law

Ref. Page 66 Chapter 06: Boolean Algebra and Logic Circuits Slide 12/86
Computer Fundamentals : Pradeep K. Sinha & Priti Sinha

Methods of Proving Theorems


The theorems of Boolean algebra may be proved by using

one of the following methods:

1. By using postulates to show that L.H.S. = R.H.S

2. By Perfect Induction or Exhaustive Enumeration method


where all possible combinations of variables involved in
L.H.S. and R.H.S. are checked to yield identical results

3. By the Principle of Duality where the dual of an already


proved theorem is derived from the proof of its
corresponding pair

Ref. Page 66 Chapter 06: Boolean Algebra and Logic Circuits Slide 13/86
Computer Fundamentals : Pradeep K. Sinha & Priti Sinha
Proving a Theorem by Using Postulates
(Example)

Theorem:

x+x·y=x

Proof:
L.H.S.
= xxy
= x1xy by postulate 2(b)
= x  (1  y) by postulate 5(a)
= x  (y  1) by postulate 3(a)
= x1 by theorem 2(a)
= x by postulate 2(b)
= R.H.S.

Ref. Page 67 Chapter 06: Boolean Algebra and Logic Circuits Slide 14/86
Computer Fundamentals : Pradeep K. Sinha & Priti Sinha
Proving a Theorem by Perfect Induction
(Example)
Theorem:

x + x ·y = x
=

x y xy xxy

0 0 0 0

0 1 0 0

1 0 0 1

1 1 1 1

Ref. Page 67 Chapter 06: Boolean Algebra and Logic Circuits Slide 15/86
Computer Fundamentals : Pradeep K. Sinha & Priti Sinha
Proving a Theorem by the
Principle of Duality (Example)

Theorem:

x+x=x

Proof:

L.H.S.
=xx
= (x  x)  1 by postulate 2(b)
= (x  x)  (x + X) by postulate 6(a)
= x  x X by postulate 5(b)
=x0 by postulate 6(b)
=x by postulate 2(a)
= R.H.S.

(Continued on next slide)

Ref. Page 66 Chapter 06: Boolean Algebra and Logic Circuits Slide 16/86
Computer Fundamentals : Pradeep K. Sinha & Priti Sinha
Proving a Theorem by the
Principle of Duality (Example)

Dual Theorem:

xx=x

Proof:

L.H.S.
=xx
=xx0 by postulate 2(a) Notice that each step of
the proof of the dual
= x  x  x X by postulate 6(b)
theorem is derived from
= x  (x + X ) by postulate 5(a) the proof of its
=x1 by postulate 6(a) corresponding pair in
=x by postulate 2(b) the original theorem
= R.H.S.

Ref. Page 66 Chapter 06: Boolean Algebra and Logic Circuits Slide 17/86
Computer Fundamentals : Pradeep K. Sinha & Priti Sinha

Boolean Functions

Chapter 06: Boolean Algebra and Logic Circuits Slide 18/86


Computer Fundamentals : Pradeep K. Sinha & Priti Sinha

Boolean Functions

 A Boolean function is an expression formed with:

 Binary variables

 Operators (OR, AND, and NOT)

 Parentheses, and equal sign

 The value of a Boolean function can be either 0 or 1

 A Boolean function may be represented as:

 An algebraic expression, or

 A truth table

Ref. Page 70 Chapter 06: Boolean Algebra and Logic Circuits Slide 19/86
Computer Fundamentals : Pradeep K. Sinha & Priti Sinha

Representation as an Algebraic Expression

W = X + Y ·Z
 Variable W is a function of X, Y, and Z, can also be
written as W = f (X, Y, Z)

 The RHS of the equation is called an expression

 The symbols X, Y, Z are the literals of the function

 For a given Boolean function, there may be more than


one algebraic expressions

Ref. Page 70 Chapter 06: Boolean Algebra and Logic Circuits Slide 20/86
Computer Fundamentals : Pradeep K. Sinha & Priti Sinha

Representation as a Truth Table

X Y Z W
0 0 0 0
0 0 1 1
0 1 0 0
0 1 1 0
1 0 0 1
1 0 1 1
1 1 0 1
1 1 1 1

W= X+ Y Z

(Continued on next slide)

Ref. Page 70 Chapter 06: Boolean Algebra and Logic Circuits Slide 21/86
Computer Fundamentals : Pradeep K. Sinha & Priti Sinha

Representation as a Truth Table

 The number of rows in the table is equal to 2n, where


n is the number of literals in the function

 The combinations of 0s and 1s for rows of this table


are obtained from the binary numbers by counting
from 0 to 2n - 1

Ref. Page 70 Chapter 06: Boolean Algebra and Logic Circuits Slide 22/86
Computer Fundamentals : Pradeep K. Sinha & Priti Sinha

Minimization of Boolean Functions

 Minimization of Boolean functions deals with


 Reduction in number of literals
 Reduction in number of terms

 Minimization is achieved through manipulating


expression to obtain equal and simpler expression(s)
(having fewer literals and/or terms)

(Continued on next slide)

Ref. Page 71 Chapter 06: Boolean Algebra and Logic Circuits Slide 23/86
Computer Fundamentals : Pradeep K. Sinha & Priti Sinha

Minimization of Boolean Functions

F1 = x  y  z + x  y  z + x  y
F1 has 3 literals (x, y, z) and 3 terms

F2 = x  y + x  z
F2 has 3 literals (x, y, z) and 2 terms

F2 can be realized with fewer electronic components,


resulting in a cheaper circuit

(Continued on next slide)

Ref. Page 71 Chapter 06: Boolean Algebra and Logic Circuits Slide 24/86
Computer Fundamentals : Pradeep K. Sinha & Priti Sinha

Minimization of Boolean Functions

x y z F1 F2
0 0 0 0 0
0 0 1 1 1
0 1 0 0 0
0 1 1 1 1
1 0 0 1 1
1 0 1 1 1
1 1 0 0 0
1 1 1 0 0

Both F1 and F2 produce the same result

Ref. Page 71 Chapter 06: Boolean Algebra and Logic Circuits Slide 25/86
Computer Fundamentals : Pradeep K. Sinha & Priti Sinha
Try out some Boolean Function
Minimization

(a) x  x  y

(b) x  x  y 
(c) x  y  z  x  y  z  x  y
(d) x  y  x  z  y  z
(e)  x  y    x  z    y z 

Ref. Page 71 Chapter 06: Boolean Algebra and Logic Circuits Slide 26/86
Computer Fundamentals : Pradeep K. Sinha & Priti Sinha

Complement of a Boolean Function

 The complement of a Boolean function is obtained by


interchanging:

 Operators OR and AND

 Complementing each literal

 This is based on De Morgan’s theorems, whose


general form is:

A +A +A +...+A =A A A ...A
1 2 3 n 1 2 3 n

A A A ...A =A +A +A +...+A
1 2 3 n 1 2 3 n

Ref. Page 72 Chapter 06: Boolean Algebra and Logic Circuits Slide 27/86
Computer Fundamentals : Pradeep K. Sinha & Priti Sinha
Complementing a Boolean
Function (Example)

F = x  y  z+ x  y  z
1

To obtain F1, we first interchange the OR and the AND


operators giving

 x+ y+z    x+ y+z 
Now we complement each literal giving

F =  x+ y +z    x+ y+ z 
1

Ref Page. 73 Chapter 06: Boolean Algebra and Logic Circuits Slide 28/86
Computer Fundamentals : Pradeep K. Sinha & Priti Sinha

Canonical Forms of Boolean Functions

Minterms : n variables forming an AND term, with


each variable being primed or unprimed,
provide 2n possible combinations called
minterms or standard products

Maxterms : n variables forming an OR term, with


each variable being primed or unprimed,
provide 2n possible combinations called
maxterms or standard sums

Ref. Page 74 Chapter 06: Boolean Algebra and Logic Circuits Slide 29/86
Computer Fundamentals : Pradeep K. Sinha & Priti Sinha

Minterms and Maxterms for three Variables

Variables Minterms Maxterms


x y z Term Designation Term Designation
0 0 0 x  yz m0 xyz M 0

0 0 1
x  yz m1 xyz M 1

0 1 0
x  yz m2 xyz M 2

0 1 1
x  yz m3 xyz M 3

1 0 0 x  yz m4 xyz M 4

1 0 1 x  yz m5 xyz M 5

1 1 0 x  yz m6 x yz M 6

1 1 1 x  yz m7 xyz M 7

Note that each minterm is the complement of its corresponding maxterm and vice-versa

Ref. Page 75 Chapter 06: Boolean Algebra and Logic Circuits Slide 30/86
Computer Fundamentals : Pradeep K. Sinha & Priti Sinha

Sum-of-Products (SOP) Expression

A sum-of-products (SOP) expression is a product term


(minterm) or several product terms (minterms) logically
added (ORed) together. Examples are:

x x+ y
x+ y  z x  y+z
xy + xy x  y + x y z

Ref. Page 75 Chapter 06: Boolean Algebra and Logic Circuits Slide 31/86
Computer Fundamentals : Pradeep K. Sinha & Priti Sinha
Steps to Express a Boolean Function
in its Sum-of-Products Form

1. Construct a truth table for the given Boolean function

2. Form a minterm for each combination of the


variables, which produces a 1 in the function

3. The desired expression is the sum (OR) of all the


minterms obtained in Step 2

Ref. Page 75 Chapter 06: Boolean Algebra and Logic Circuits Slide 32/86
Computer Fundamentals : Pradeep K. Sinha & Priti Sinha
Expressing a Function in its
Sum-of-Products Form (Example)

x y z F1
0 0 0 0
0 0 1 1
0 1 0 0
0 1 1 0
1 0 0 1
1 0 1 0
1 1 0 0
1 1 1 1

The following 3 combinations of the variables produce a 1 in case of F1 :


001, 100, and 111
(Continued on next slide)

Ref. Page 75 Chapter 06: Boolean Algebra and Logic Circuits Slide 33/86
Computer Fundamentals : Pradeep K. Sinha & Priti Sinha
Expressing a Function in its
Sum-of-Products Form (Example)

 Their corresponding minterms are:

x  y  z, x  y  z, and x  y  z
 Taking the OR of these minterms, we get

F1 =x  y  z+x  y  z+x  y  z=m1+m4  m7


F1  x  y  z  =  1,4,7 

Ref. Page 75 Chapter 06: Boolean Algebra and Logic Circuits Slide 34/86
Computer Fundamentals : Pradeep K. Sinha & Priti Sinha

Product-of Sums (POS) Expression

A product-of-sums (POS) expression is a sum term


(maxterm) or several sum terms (maxterms) logically
multiplied (ANDed) together. Examples are:

x  x+y  x+y  x+y 


x+y  x + y  x+ y+z 
 x+y   z  x+y  x+y 

Ref. Page 77 Chapter 06: Boolean Algebra and Logic Circuits Slide 35/86
Computer Fundamentals : Pradeep K. Sinha & Priti Sinha
Steps to Express a Boolean Function
in its Product-of-Sums Form

1. Construct a truth table for the given Boolean function

2. Form a maxterm for each combination of the variables,


which produces a 0 in the function

3. The desired expression is the product (AND) of all the


maxterms obtained in Step 2

Ref. Page 77 Chapter 06: Boolean Algebra and Logic Circuits Slide 36/86
Computer Fundamentals : Pradeep K. Sinha & Priti Sinha
Expressing a Function in its
Product-of-Sums Form

x y z F1
0 0 0 0
0 0 1 1
0 1 0 0
0 1 1 0
1 0 0 1
1 0 1 0
1 1 0 0
1 1 1 1

 The following 5 combinations of variables produce a 0 in case of F1 :


000, 010, 011, 101, and 110
(Continued on next slide)

Ref. Page 77 Chapter 06: Boolean Algebra and Logic Circuits Slide 37/86
Computer Fundamentals : Pradeep K. Sinha & Priti Sinha
Expressing a Function in its
Product-of-Sums Form
 Their corresponding maxterms are:

 x+y+ z ,  x+y+ z ,  x+y+ z ,


 x+y+ z  and  x+y+ z 
 Taking the AND of these maxterms, we get:

F1 =  x+y+z   x+y+z   x+y+z   x+y+z  


 x+y+z  =M M M  M M
0 2 3 5 6

F1  x,y,z  = Π 0,2,3,5,6 
Ref. Page 77 Chapter 06: Boolean Algebra and Logic Circuits Slide 38/86
Computer Fundamentals : Pradeep K. Sinha & Priti Sinha
Conversion Between Canonical Forms
(Sum-of-Products and Product-of-Sums)

To convert from one canonical form to another,


interchange the symbol and list those numbers missing
from the original form.

Example:

    
F x,y,z = Π 0,2,4,5 = Σ 1,3,6,7 
F x,y,z  = Σ 1,4,7  = Σ  0,2,3,5,6 

Ref. Page 78 Chapter 06: Boolean Algebra and Logic Circuits Slide 39/86
Computer Fundamentals : Pradeep K. Sinha & Priti Sinha

Logic Gates

Chapter 06: Boolean Algebra and Logic Circuits Slide 40/86


Computer Fundamentals : Pradeep K. Sinha & Priti Sinha

Logic Gates

 Logic gates are electronic circuits that operate on one


or more input signals to produce standard output
signal

 Are the building blocks of all the circuits in a computer

 Some of the most basic and useful logic gates are


AND, OR, NOT, NAND and NOR gates

Ref. Page 79 Chapter 06: Boolean Algebra and Logic Circuits Slide 41/86
Computer Fundamentals : Pradeep K. Sinha & Priti Sinha

AND Gate

 Physical realization of logical multiplication (AND)


operation

 Generates an output signal of 1 only if all input


signals are also 1

Ref. Page 80 Chapter 06: Boolean Algebra and Logic Circuits Slide 42/86
Computer Fundamentals : Pradeep K. Sinha & Priti Sinha
AND Gate (Block Diagram Symbol
and Truth Table)

A
C= AB
B

Inputs Output

A B C=AB
0 0 0
0 1 0
1 0 0
1 1 1

Ref. Page 80 Chapter 06: Boolean Algebra and Logic Circuits Slide 43/86
Computer Fundamentals : Pradeep K. Sinha & Priti Sinha

OR Gate

 Physical realization of logical addition (OR) operation

 Generates an output signal of 1 if at least one of the


input signals is also 1

Ref. Page 80 Chapter 06: Boolean Algebra and Logic Circuits Slide 44/86
Computer Fundamentals : Pradeep K. Sinha & Priti Sinha
OR Gate (Block Diagram Symbol
and Truth Table)

A
C=A+B
B

Inputs Output

A B C=A +B

0 0 0

0 1 1

1 0 1

1 1 1

Ref. Page 80 Chapter 06: Boolean Algebra and Logic Circuits Slide 45/86
Computer Fundamentals : Pradeep K. Sinha & Priti Sinha

NOT Gate

 Physical realization of complementation operation

 Generates an output signal, which is the reverse of


the input signal

Ref. Page 81 Chapter 06: Boolean Algebra and Logic Circuits Slide 46/86
Computer Fundamentals : Pradeep K. Sinha & Priti Sinha
NOT Gate (Block Diagram Symbol
and Truth Table)

A A

Input Output

A A
0 1

1 0

Ref. Page 81 Chapter 06: Boolean Algebra and Logic Circuits Slide 47/86
Computer Fundamentals : Pradeep K. Sinha & Priti Sinha

NAND Gate

 Complemented AND gate

 Generates an output signal of:

 1 if any one of the inputs is a 0

 0 when all the inputs are 1

Ref. Page 82 Chapter 06: Boolean Algebra and Logic Circuits Slide 48/86
Computer Fundamentals : Pradeep K. Sinha & Priti Sinha
NAND Gate (Block Diagram Symbol
and Truth Table)

A
B C=A B=A B=A +B

Inputs Output

A B C =A +B
0 0 1

0 1 1

1 0 1

1 1 0

Ref. Page 82 Chapter 06: Boolean Algebra and Logic Circuits Slide 49/86
Computer Fundamentals : Pradeep K. Sinha & Priti Sinha

NOR Gate

 Complemented OR gate

 Generates an output signal of:

 1 only when all inputs are 0

 0 if any one of inputs is a 1

Ref. Page 82 Chapter 06: Boolean Algebra and Logic Circuits Slide 50/86
Computer Fundamentals : Pradeep K. Sinha & Priti Sinha
NOR Gate (Block Diagram Symbol
and Truth Table)

A
B C=A B=A  B=A  B

Inputs Output

A B C =A  B
0 0 1

0 1 0

1 0 0

1 1 0

Ref. Page 82 Chapter 06: Boolean Algebra and Logic Circuits Slide 51/86
Computer Fundamentals : Pradeep K. Sinha & Priti Sinha

Logic Cicruits

Chapter 06: Boolean Algebra and Logic Circuits Slide 52/86


Computer Fundamentals : Pradeep K. Sinha & Priti Sinha

Logic Circuits

 When logic gates are interconnected to form a gating /


logic network, it is known as a combinational logic circuit

 The Boolean algebra expression for a given logic circuit


can be derived by systematically progressing from input
to output on the gates

 The three logic gates (AND, OR, and NOT) are logically
complete because any Boolean expression can be
realized as a logic circuit using only these three gates

Ref. Page 83 Chapter 06: Boolean Algebra and Logic Circuits Slide 53/86
Computer Fundamentals : Pradeep K. Sinha & Priti Sinha
Finding Boolean Expression
of a Logic Circuit (Example 1)

A
A

NOT D= A  B + C 

B B+C AND
C
OR

Ref. Page 83 Chapter 06: Boolean Algebra and Logic Circuits Slide 54/86
Computer Fundamentals : Pradeep K. Sinha & Priti Sinha
Finding Boolean Expression
of a Logic Circuit (Example 2)

OR
A A B
B


C=  A +B   A  B 
A B A B AND

AND NOT

Ref. Page 85 Chapter 06: Boolean Algebra and Logic Circuits Slide 55/86
Computer Fundamentals : Pradeep K. Sinha & Priti Sinha
Constructing a Logic Circuit from a Boolean
Expression (Example 1)

Boolean Expression = A B+C

AND
A A B
B
A B+C
C
OR

Ref. Page 86 Chapter 06: Boolean Algebra and Logic Circuits Slide 56/86
Computer Fundamentals : Pradeep K. Sinha & Priti Sinha
Constructing a Logic Circuit from a Boolean
Expression (Example 2)
Boolean Expression = A B+C D+E F

AND NOT
A A B A B
B
AND AND
C C D
D A B+C D+E F
AND
E E F E F
F NOT

Ref. Page 86 Chapter 06: Boolean Algebra and Logic Circuits Slide 57/86
Computer Fundamentals : Pradeep K. Sinha & Priti Sinha

Universal NAND Gate

 NAND gate is an universal gate, it is alone


sufficient to implement any Boolean
expression

 To understand this, consider:

 Basic logic gates (AND, OR, and NOT) are


logically complete

 Sufficient to show that AND, OR, and NOT


gates can be implemented with NAND
gates

Ref. Page 87 Chapter 06: Boolean Algebra and Logic Circuits Slide 58/86
Computer Fundamentals : Pradeep K. Sinha & Priti Sinha
Implementation of NOT, AND and OR
Gates by NAND Gates

AA=A+A=A
A
(a) NOT gate implementation.

A A B A  B  A B
B
(b) AND gate implementation.

(Continued on next slide)

Ref. Page 87 Chapter 06: Boolean Algebra and Logic Circuits Slide 59/86
Computer Fundamentals : Pradeep K. Sinha & Priti Sinha
Implementation of NOT, AND and OR
Gates by NAND Gates

A  A =A
A
A B  A +B  A  B
B B=B
B
(c) OR gate implementation.

Ref. Page 87 Chapter 06: Boolean Algebra and Logic Circuits Slide 60/86
Computer Fundamentals : Pradeep K. Sinha & Priti Sinha
Method of Implementing a Boolean
Expression with Only NAND Gates

Step 1: From the given algebraic expression, draw the logic


diagram with AND, OR, and NOT gates. Assume that
both the normal (A) and complement (A) inputs are
available

Step 2: Draw a second logic diagram with the equivalent NAND


logic substituted for each AND, OR, and NOT gate

Step 3: Remove all pairs of cascaded inverters from the


diagram as double inversion does not perform any
logical function. Also remove inverters connected to
single external inputs and complement the
corresponding input variable

Ref. Page 88 Chapter 06: Boolean Algebra and Logic Circuits Slide 61/86
Computer Fundamentals : Pradeep K. Sinha & Priti Sinha
Implementing a Boolean Expression with
Only NAND Gates (Example)

Boolean Expression = A  B +C   A +B D 

A A B
A  B +C   A +B D 
B

B B D
D A +B D
A
C C   A +B D 

(a) Step 1: AND/OR implementation


(Continued on next slide)

Ref. Page 89 Chapter 06: Boolean Algebra and Logic Circuits Slide 62/86
Computer Fundamentals : Pradeep K. Sinha & Priti Sinha
Implementing a Boolean Expression with
Only NAND Gates (Example)
AND
OR
A A B
1
B
5

AND OR
B B D
2
D A+BD
A  B + C  A+B D 
3

AND

C  A+B D 
4
C

(b) Step 2: Substituting equivalent NAND functions


(Continued on next slide)

Ref. Page 89 Chapter 06: Boolean Algebra and Logic Circuits Slide 63/86
Computer Fundamentals : Pradeep K. Sinha & Priti Sinha
Implementing a Boolean Expression with
Only NAND Gates (Example)

A
1
B A  B + C   A +B D 
5
B
2
D
3
A
4
C

(c) Step 3: NAND implementation.

Ref. Page 89 Chapter 06: Boolean Algebra and Logic Circuits Slide 64/86
Computer Fundamentals : Pradeep K. Sinha & Priti Sinha

Universal NOR Gate

 NOR gate is an universal gate, it is alone sufficient to


implement any Boolean expression

 To understand this, consider:

 Basic logic gates (AND, OR, and NOT) are logically


complete

 Sufficient to show that AND, OR, and NOT gates can


be implemented with NOR gates

Ref. Page 91 Chapter 06: Boolean Algebra and Logic Circuits Slide 65/86
Computer Fundamentals : Pradeep K. Sinha & Priti Sinha
Implementation of NOT, OR and AND
Gates by NOR Gates

A  A =AA =A
A

(a) NOT gate implementation.

A A B A  B  A B
B

(b) OR gate implementation.

(Continued on next slide)

Ref. Page 91 Chapter 06: Boolean Algebra and Logic Circuits Slide 66/86
Computer Fundamentals : Pradeep K. Sinha & Priti Sinha
Implementation of NOT, OR and AND
Gates by NOR Gates

A A  A =A
A +B  A B  A B

B  B=B
B

(c) AND gate implementation.

Ref. Page 91 Chapter 06: Boolean Algebra and Logic Circuits Slide 67/86
Computer Fundamentals : Pradeep K. Sinha & Priti Sinha
Method of Implementing a Boolean
Expression with Only NOR Gates

Step 1: For the given algebraic expression, draw the logic


diagram with AND, OR, and NOT gates. Assume that
both the normal  A  and complement A inputs are
available
 
Step 2: Draw a second logic diagram with equivalent NOR logic
substituted for each AND, OR, and NOT gate

Step 3: Remove all parts of cascaded inverters from the


diagram as double inversion does not perform any
logical function. Also remove inverters connected to
single external inputs and complement the
corresponding input variable

Ref. Page 92 Chapter 06: Boolean Algebra and Logic Circuits Slide 68/86
Computer Fundamentals : Pradeep K. Sinha & Priti Sinha
Implementing a Boolean Expression with
Only NOR Gates (Examples)

Boolean Expression A  B + C   A +B D 
=
A A B
B A  B + C   A +B D 
B B D
D A +B D
A
C C   A +B D 
(a) Step 1: AND/OR implementation.

(Continued on next slide)

Ref. Page 93 Chapter 06: Boolean Algebra and Logic Circuits Slide 69/86
Computer Fundamentals : Pradeep K. Sinha & Priti Sinha
Implementing a Boolean Expression with
Only NOR Gates (Examples)

AN
A D
A B
1
OR
A  B + C  A +B D 
B
5 6
AN
B D
B D
2

D OR
AN
3 D
A
C  A +B D 
4

C
A+BD
(b) Step 2: Substituting equivalent NOR functions.
(Continued on next slide)

Ref. Page 93 Chapter 06: Boolean Algebra and Logic Circuits Slide 70/86
Computer Fundamentals : Pradeep K. Sinha & Priti Sinha
Implementing a Boolean Expression with
Only NOR Gates (Examples)

A 1
B A  B + C   A +B D 
5 6

B 2
D
3
A
4
C
(c) Step 3: NOR implementation.

Ref. Page 93 Chapter 06: Boolean Algebra and Logic Circuits Slide 71/86
Computer Fundamentals : Pradeep K. Sinha & Priti Sinha

Exclusive-OR Function

A  B =A  B + A  B

A C = A  B = A B+ A B
B

A  C = A  B = A B+ A B
B

Also,  A  B   C = A  B  C  = A  B  C

(Continued on next slide)

Ref. Page 94 Chapter 06: Boolean Algebra and Logic Circuits Slide 72/86
Computer Fundamentals : Pradeep K. Sinha & Priti Sinha

Exclusive-OR Function (Truth Table)

Inputs Output

A B C =A  B
0 0 0

0 1 1

1 0 1

1 1 0

Ref. Page 94 Chapter 06: Boolean Algebra and Logic Circuits Slide 73/86
Computer Fundamentals : Pradeep K. Sinha & Priti Sinha
Equivalence Function with Block Diagram
Symbol

A  B = A  B+ A  B

A C = A  B = A B+ A B
B

Also, (A  B)  = A  (B  C) = A  B  C

(Continued on next slide)

Ref. Page 94 Chapter 06: Boolean Algebra and Logic Circuits Slide 74/86
Computer Fundamentals : Pradeep K. Sinha & Priti Sinha

Equivalence Function (Truth Table)

Inputs Output

A B C=AB

0 0 1

0 1 0

1 0 0

1 1 1

Ref. Page 94 Chapter 06: Boolean Algebra and Logic Circuits Slide 75/86
Computer Fundamentals : Pradeep K. Sinha & Priti Sinha

Design of
Combinational Circuits

Chapter 06: Boolean Algebra and Logic Circuits Slide 76/86


Computer Fundamentals : Pradeep K. Sinha & Priti Sinha

Steps in Designing Combinational Circuits

1. State the given problem completely and exactly

2. Interpret the problem and determine the available input


variables and required output variables

3. Assign a letter symbol to each input and output variables

4. Design the truth table that defines the required relations


between inputs and outputs

5. Obtain the simplified Boolean function for each output

6. Draw the logic circuit diagram to implement the Boolean


function

Ref. Page 95 Chapter 06: Boolean Algebra and Logic Circuits Slide 77/86
Computer Fundamentals : Pradeep K. Sinha & Priti Sinha
Designing a Combinational Circuit
Example 1 – Half-Adder Design

Inputs Outputs
A B C S
0 0 0 0
0 1 0 1
1 0 0 1
1 1 1 0

S = A B+A B
Boolean functions for the two outputs.
C = A B

Ref. Page 96 Chapter 06: Boolean Algebra and Logic Circuits Slide 78/86
Computer Fundamentals : Pradeep K. Sinha & Priti Sinha
Designing a Combinational Circuit
Example 1 – Half-Adder Design

A A B
A

S = A B+ A B

B
B A B

A
B C = A B

Logic circuit diagram to implement the Boolean functions

Ref. Page 96 Chapter 06: Boolean Algebra and Logic Circuits Slide 79/86
Computer Fundamentals : Pradeep K. Sinha & Priti Sinha
Designing a Combinational Circuit
Example 2 – Full-Adder Design

Inputs Outputs
A B D C S
0 0 0 0 0
0 0 1 0 1
0 1 0 0 1
0 1 1 1 0
1 0 0 0 1
1 0 1 1 0
1 1 0 1 0
1 1 1 1 1
Truth table for a full adder
(Continued on next slide)

Ref. Page 97 Chapter 06: Boolean Algebra and Logic Circuits Slide 80/86
Computer Fundamentals : Pradeep K. Sinha & Priti Sinha
Designing a Combinational Circuit
Example 2 – Full-Adder Design

Boolean functions for the two outputs:

S = A B D+ A B D+ A B D+ A B D


C = A B D+ A B D+ A B D+ A B D
= A B+ A D+B D (when simplified)

(Continued on next slide)

Ref. Page 97 Chapter 06: Boolean Algebra and Logic Circuits Slide 81/86
Computer Fundamentals : Pradeep K. Sinha & Priti Sinha
Designing a Combinational Circuit
Example 2 – Full-Adder Design

A A B D
B
D

A A B D
B
D
S
A
B A B D
D

A A B D
B
D

(a) Logic circuit diagram for sums


(Continued on next slide)

Ref. Page 98 Chapter 06: Boolean Algebra and Logic Circuits Slide 82/86
Computer Fundamentals : Pradeep K. Sinha & Priti Sinha
Designing a Combinational Circuit
Example 2 – Full-Adder Design

A A B
B

A A D C
D

B BD
D

(b) Logic circuit diagram for carry

Ref. Page 98 Chapter 06: Boolean Algebra and Logic Circuits Slide 83/86
Computer Fundamentals : Pradeep K. Sinha & Priti Sinha
Designing a Combinational Circuit:
Full-Adder Design using Half-Adders

AB
A
HA C
AB AB  A B  A  B  D
B
HA
D S
A BD

Ref. Page 98 Chapter 06: Boolean Algebra and Logic Circuits Slide 84/86
Computer Fundamentals : Pradeep K. Sinha & Priti Sinha

Parallel Binary Adder

A4 A3 A2 A1
B4 B3 B2 B1

FA FA FA HA
Carry Carry Carry

S5 S4 S3 S2 S1

Ref. Page 99 Chapter 06: Boolean Algebra and Logic Circuits Slide 85/86
Computer Fundamentals : Pradeep K. Sinha & Priti Sinha

Key Words/Phrases
 Absorption law  Equivalence function  NOT gate
 AND gate  Exclusive-OR function  Operator precedence
 Associative law  Exhaustive enumeration  OR gate
 Boolean algebra method  Parallel Binary Adder
 Boolean expression  Half-adder  Perfect induction
 Boolean functions  Idempotent law method
 Boolean identities  Involution law  Postulates of Boolean
 Canonical forms for  Literal algebra
Boolean functions  Logic circuits  Principle of duality
 Combinational logic  Logic gates  Product-of-Sums
circuits  Logical addition expression
 Cumulative law  Logical multiplication  Standard forms
 Complement of a  Maxterms  Sum-of Products
function  Minimization of Boolean expression
 Complementation functions  Truth table
 De Morgan’s law  Minterms  Universal NAND gate
 Distributive law  NAND gate  Universal NOR gate
 Dual identities

Chapter 06: Boolean Algebra and Logic Circuits Slide 86/86


Computer Fundamentals : Pradeep K. Sinha & Priti Sinha

Computer Fundamentals

Pradeep K. Sinha
Priti Sinha

Chapter 7

Processor and
Memory
Chapter 07: Processor and Memory Slide 1/32
Computer Fundamentals : Pradeep K. Sinha & Priti Sinha

Learning Objectives

In this chapter you will learn about:

 Internal structure of processor


 Memory structure
 Determining the speed of a processor
 Different types of processors available
 Determining the capacity of a memory
 Different types of memory available
 Several other terms related to the processor and
main memory of a computer system

Chapter 07: Processor and Memory Slide 2/32


Computer Fundamentals : Pradeep K. Sinha & Priti Sinha
Basic Processor & Memory Architecture
of a Computer System
ROM PROM EPROM
Main memory (RAM)

Cache memory

S
E
Accumulator
C Decoder
register
O I/O
N Program control General-purpose
D
D register register D
E
A E
V Storage Instruction General-purpose I/O
R V
I interfaces register register interfaces
Y I
C Memory address
S C
E register
T E
S
O Memory buffer S
R register
A
I/O
G
register
E
General-purpose General-purpose
register register

Control Unit Arithmetic Logic Unit


Central Processing Unit

Ref. Page 105 Chapter 07: Processor and Memory Slide 3/32
Computer Fundamentals : Pradeep K. Sinha & Priti Sinha

Central Processing
Unit (CPU)

Chapter 07: Processor and Memory Slide 4/32


Computer Fundamentals : Pradeep K. Sinha & Priti Sinha

Central Processing Unit (CPU)


 The brain of a computer system
 Performs all major calculations and comparisons
 Activates and controls the operations of other units of a
computer system
 Two basic components are
 Control Unit (CU)
 Arithmetic Logic Unit (ALU)

 No other single component of a computer determines


its overall performance as much as the CPU

Ref. Page 104 Chapter 07: Processor and Memory Slide 5/32
Computer Fundamentals : Pradeep K. Sinha & Priti Sinha

Control Unit (CU)


 One of the two basic components of CPU
 Acts as the central nervous system of a computer
system
 Selects and interprets program instructions, and
coordinates execution
 Has some special purpose registers and a decoder to
perform these activities

Ref. Page 105 Chapter 07: Processor and Memory Slide 6/32
Computer Fundamentals : Pradeep K. Sinha & Priti Sinha

Arithmetic Logic Unit (ALU)


 One of the two basic components of CPU.
 Actual execution of instructions takes place in ALU
 Has some special purpose registers
 Has necessary circuitry to carry out all the
arithmetic and logic operations included in the CPU
instruction set

Ref. Page 106 Chapter 07: Processor and Memory Slide 7/32
Computer Fundamentals : Pradeep K. Sinha & Priti Sinha

Instruction Set
 CPU has built-in ability to execute a particular set of machine
instructions, called its instruction set
 Most CPUs have 200 or more instructions (such as add,
subtract, compare, etc.) in their instruction set
 CPUs made by different manufacturers have different
instruction sets
 Manufacturers tend to group their CPUs into “families” having
similar instruction sets
 New CPU whose instruction set includes instruction set of its
predecessor CPU is said to be backward compatible with its
predecessor

Ref. Page 106 Chapter 07: Processor and Memory Slide 8/32
Computer Fundamentals : Pradeep K. Sinha & Priti Sinha

Registers

 Special memory units, called registers, are used to


hold information on a temporary basis as the
instructions are interpreted and executed by the CPU
 Registers are part of the CPU (not main memory) of a
computer
 The length of a register, sometimes called its word
size, equals the number of bits it can store
 With all other parameters being the same, a CPU with
32-bit registers can process data twice larger than
one with 16-bit registers

Ref. Page 106 Chapter 07: Processor and Memory Slide 9/32
Computer Fundamentals : Pradeep K. Sinha & Priti Sinha

Functions of Commonly Used Registers

Sr. No. Name of register Function


Holds address of the active memory
1 Memory Address (MAR)
location
Holds information on its way to and from
2 Memory Buffer (MBR)
memory
Holds address of the next instruction to be
3 Program Control (PC)
executed
Accumulates results and data to be
4 Accumulator (A)
operated upon
Holds an instruction while it is being
5 Instruction (I)
executed

6 Input/Output (I/O) Communicates with I/O devices

Ref. Page 107 Chapter 07: Processor and Memory Slide 10/32
Computer Fundamentals : Pradeep K. Sinha & Priti Sinha

Execution of Instructions
 Control unit takes address of the next program instruction
to be executed from program control register and reads
the instruction from corresponding memory address into
the instruction register
 Control unit then sends the operation and address parts of
the instruction to the decoder and memory address
register
 Decoder interprets the instruction and accordingly the
control unit sends command signals to the appropriate
unit for carrying out the task specified in the instruction
 As each instruction is executed, address of next
instruction is loaded and steps are repeated

Ref. Page 107 Chapter 07: Processor and Memory Slide 11/32
Computer Fundamentals : Pradeep K. Sinha & Priti Sinha

Processor Speed

 Computer has a built-in system clock that emits millions of


regularly spaced electric pulses per second (known as clock cycles)
 It takes one cycle to perform a basic operation, such as moving a
byte of data from one memory location to another
 Normally, several clock cycles are required to fetch, decode, and
execute a single program instruction
 Hence, shorter the clock cycle, faster the processor
 Clock speed (number of clock cycles per second) is measured in
Megahertz (106 cycles/sec) or Gigahertz (109 cycles/sec)
 We measure processing speed of PCs in MHz or GHz, of
workstations and servers in MIPS or BIPS, and of supercomputers
in GFLOPS (gigaflops, which refers to a billion FLOPS) or TFLOPS
(teraflops, which refers to 1012 FLOPS), or PFLOPS (petaflops,
which refers to 1015 FLOPS)

Ref. Page 108 Chapter 07: Processor and Memory Slide 12/32
Computer Fundamentals : Pradeep K. Sinha & Priti Sinha

Types of Processors

Type of
Features Usage
Architecture
 Large instruction set
CISC (Complex  Variable-length instructions Mostly used in
Instruction Set  Variety of addressing modes personal
Computer)  Complex & expensive to computers
produce
 Small instruction set
RISC (Reduced
 Fixed-length instructions Mostly used in
Instruction Set
 Reduced references to workstations
Computer)
memory to retrieve operands

(Continued on next slide)

Ref. Page 108 Chapter 07: Processor and Memory Slide 13/32
Computer Fundamentals : Pradeep K. Sinha & Priti Sinha

Types of Processors

Type of
Features Usage
Architecture
 Allows software to
communicate explicitly to the
processor when operations
are parallel
EPIC (Explicitly
 Uses tighter coupling Mostly used in
Parallel
between the compiler and the high-end servers
Instruction
processor and workstations
Computing)
 Enables compiler to extract
maximum parallelism in the
original code, and explicitly
describe it to the processor

(Continued on next slide)

Ref. Page 109 Chapter 07: Processor and Memory Slide 14/32
Computer Fundamentals : Pradeep K. Sinha & Priti Sinha

Types of Processors

Type of
Features Usage
Architecture
 Processor chip has multiple
cooler-running, more energy-
efficient processing cores
 Improve overall performance
Mostly used in
Multi-Core by handling more work in
high-end servers
Processor parallel
and workstations
 can share architectural
components, such as memory
elements and memory
management

Ref. Page 111 Chapter 07: Processor and Memory Slide 15/32
Computer Fundamentals : Pradeep K. Sinha & Priti Sinha

Power-Efficient Processors

 Manufacturers of computing systems have made attempts


to reduce power consumption of systems
 New processor architectures to reduce power
consumption right at processor level
 latest processor offers a technology called Demand Based
Switching (DBS) for reduced power consumption
 Processors based on DBS technology are designed to run
at multiple frequency and voltage settings
 processors automatically switch to and operate at the
lowest setting that is consistent with optimal application
performance

Ref. Page 112 Chapter 07: Processor and Memory Slide 16/32
Computer Fundamentals : Pradeep K. Sinha & Priti Sinha

Main Memory

Chapter 07: Processor and Memory Slide 17/32


Computer Fundamentals : Pradeep K. Sinha & Priti Sinha

Main Memory
 Every computer has a temporary storage built into
the computer hardware
 It stores instructions and data of a program mainly
when the program is being executed by the CPU
 This temporary storage is known as main memory,
primary storage, or simply memory
 Physically, it consists of some chips either on the
motherboard or on a small circuit board attached to
the motherboard of a computer
 It has random access property
 It is volatile

Ref. Page 112 Chapter 07: Processor and Memory Slide 18/32
Computer Fundamentals : Pradeep K. Sinha & Priti Sinha

Storage Evaluation Criteria


Primary Secondary
Property Desirable
storage storage

Storage
Large storage capacity Small Large
capacity

Access Time Fast access time Fast Slow


Cost per bit of
Lower cost per bit High Low
storage
Volatility Non-volatile Volatile Non-volatile
Pseudo-
random
Random
Access Random access access or
access
sequential
access

Ref. Page 113 Chapter 07: Processor and Memory Slide 19/32
Computer Fundamentals : Pradeep K. Sinha & Priti Sinha

Main Memory Organization

0
1
2
3
Addresses of 4
Words of a
a memory 5 memory

N-2
N-1
Each word
Bit 1 Bit 2 contains the
same number of
bits = word
length
(Continued on next slide)

Ref. Page 114 Chapter 07: Processor and Memory Slide 20/32
Computer Fundamentals : Pradeep K. Sinha & Priti Sinha

Main Memory Organization


 Machines having smaller word-length are slower in
operation than machines having larger word-length
 A write to a memory location is destructive to its previous
contents
 A read from a memory location is non-destructive to its
previous contents

Ref. Page 114 Chapter 07: Processor and Memory Slide 21/32
Computer Fundamentals : Pradeep K. Sinha & Priti Sinha

Fixed Word-length Memory


Word
0501 B O M B A Y
0502 D E L H I
Address 0503
Numbers

1024

 Storage space is always allocated in multiples of word-length


 Faster in speed of calculation than variable word-length memory
 Normally used in large scientific computers for gaining speed of
calculation

Ref. Page 115 Chapter 07: Processor and Memory Slide 22/32
Computer Fundamentals : Pradeep K. Sinha & Priti Sinha

Variable Word-length Memory


0025 B 0051 D  Each memory location
can store only a single
0026 O
0052 E character
0027 M L
0053  Slower in speed of
0028 B 0054 H calculation than fixed
world-length memory
Address 0029 A Address I
0055
Numbers Numbers  Used in small business
0030 Y
0056 computers for
0031 optimizing the use of
storage space

4096 4096

Note: With memory becoming cheaper and larger day-by-day, most


modern computers employ fixed-word-length memory organization

Ref. Page 115 Chapter 07: Processor and Memory Slide 23/32
Computer Fundamentals : Pradeep K. Sinha & Priti Sinha

Memory Capacity
 Memory capacity of a computer is equal to the number
of bytes that can be stored in its primary storage

 Its units are:

Kilobytes (KB) : 1024 (210) bytes

Megabytes (MB) : 1,048,576 (220) bytes

Gigabytes (GB) : 1,073,741824 (230) bytes

Ref. Page 116 Chapter 07: Processor and Memory Slide 24/32
Computer Fundamentals : Pradeep K. Sinha & Priti Sinha

Types of Memory Chips

Memory chips

Volatile and writable Non-volatile and read-only

Static Dynamic Manufacturer- User-programmed


(SRAM) (DRAM) programmed
(ROM)

PROM EPROM

UVEPROM EEPROM

Ref. Page 117 Chapter 07: Processor and Memory Slide 25/32
Computer Fundamentals : Pradeep K. Sinha & Priti Sinha

Random Access Memory (RAM)


 Primary storage of a computer is often referred to as RAM
because of its random access capability
 RAM chips are volatile memory
 A computer’s motherboard is designed in a manner that
the memory capacity can be enhanced by adding more
memory chips
 The additional RAM chips, which plug into special sockets
on the motherboard, are known as single-in-line memory
modules (SIMMs)

Ref. Page 116 Chapter 07: Processor and Memory Slide 26/32
Computer Fundamentals : Pradeep K. Sinha & Priti Sinha

Read Only Memory (ROM)


 ROM a non-volatile memory chip
 Data stored in a ROM can only be read and used – they
cannot be changed
 ROMs are mainly used to store programs and data, which
do not change and are frequently used. For example,
system boot program

Ref. Page 117 Chapter 07: Processor and Memory Slide 27/32
Computer Fundamentals : Pradeep K. Sinha & Priti Sinha

Types of ROMs

Type Usage
Data is burnt by the
Manufacturer-
manufacturer of the electronic
programmed ROM
equipment in which it is used.

User-programmed ROM
or The user can load and store
“read-only” programs and data
Programmable ROM in it
(PROM)

The user can erase information


stored in it and the chip can be
Erasable PROM (EPROM)
reprogrammed to store new
information
(Continued on next slide)

Ref. Page 117 Chapter 07: Processor and Memory Slide 28/32
Computer Fundamentals : Pradeep K. Sinha & Priti Sinha

Types of ROMs

Type Usage

A type of EPROM chip in which the


Ultra Violet EPROM stored information is erased by
(UVEPROM) exposing the chip for some time
to ultra-violet light

Electrically EPROM
(EEPROM) A type of EPROM chip in which the
or stored information is erased by
using high voltage electric pulses
Flash memory

Ref. Page 117 Chapter 07: Processor and Memory Slide 29/32
Computer Fundamentals : Pradeep K. Sinha & Priti Sinha

Cache Memory
 It is commonly used for minimizing the memory-
processor speed mismatch.
 It is an extremely fast, small memory between CPU
and main memory whose access time is closer to the
processing speed of the CPU.
 It is used to temporarily store very active data and
instructions during processing.

Cache is pronounced as “cash”

Ref. Page 118 Chapter 07: Processor and Memory Slide 30/32
Computer Fundamentals : Pradeep K. Sinha & Priti Sinha

Key Words/Phrases
 Accumulator Register (AR)  Flash Memory
 Address  Input/Output Register (I/O)
 Arithmetic Logic Unit (ALU)  Instruction Register (I)
 Branch Instruction  Instruction set
 Cache Memory  Kilobytes (KB)
 Central Processing Unit (CPU)  Main Memory
 CISC (Complex Instruction Set  Manufacturer-Programmed ROM
Computer) architecture  Megabytes (MB)
 Clock cycles  Memory
 Clock speed  Memory Address Register (MAR)
 Control Unit  Memory Buffer Register (MBR)
 Electrically EPROM (EEPROM)  Microprogram
 Erasable Programmable Read-  Multi-core processor
Only Memory (EPROM)  Non-Volatile storage Processor
 Explicitly Parallel Instruction  Program Control Register (PC)
Computing (EPIC)  Programmable Read-Only Memory
 Fixed-word-length memory (PROM)
 Random Access Memory (RAM)

(Continued on next slide)

Chapter 07: Processor and Memory Slide 31/32


Computer Fundamentals : Pradeep K. Sinha & Priti Sinha

Key Words/Phrases
 Read-Only Memory (ROM)
 Register
 RISC (Reduced Instruction Set Computer)
architecture
 Single In-line Memory Module (SIMM)
 Ultra Violet EPROM (UVEPROM)
 Upward compatible
 User-Programmed ROM
 Variable-word-length memory
 Volatile Storage
 Word length
 Word size

Chapter 07: Processor and Memory Slide 32/32


Computer Fundamentals: Pradeep K. Sinha & Priti Sinha

Computer Fundamentals

Pradeep K. Sinha
Priti Sinha

Chapter 8

Secondary Storage
Devices
Chapter 08: Secondary Storage Devices Slide 1/117
Computer Fundamentals: Pradeep K. Sinha & Priti Sinha

Learning Objectives
In this chapter you will learn about:

 Secondary storage devices and their need


 Classification of commonly used secondary storage
devices
 Difference between sequential and direct access
storage devices
 Basic principles of operation, types, and uses of
popular secondary storage devices such as magnetic
tape, magnetic disk, and optical disk

(Continued on next slide)

Chapter 08: Secondary Storage Devices Slide 2/117


Computer Fundamentals: Pradeep K. Sinha & Priti Sinha

Learning Objectives

 Commonly used mass storage devices


 Introduction to other related concepts such as RAID,
Jukebox, storage hierarchy, etc.

Chapter 08: Secondary Storage Devices Slide 3/117


Computer Fundamentals: Pradeep K. Sinha & Priti Sinha

Limitations of Primary Storage

 Limited capacity because the cost per bit of storage


is high
 Volatile - data stored in it is lost when the electric
power is turned off or interrupted

Ref. Page 122 Chapter 08: Secondary Storage Devices Slide 4/117
Computer Fundamentals: Pradeep K. Sinha & Priti Sinha

Secondary Storage

 Used in a computer system to overcome the limitations


of primary storage
 Has virtually unlimited capacity because the cost per bit
of storage is very low
 Has an operating speed far slower than that of the
primary storage
 Used to store large volumes of data on a permanent
basis
 Also known as auxiliary memory

Ref. Page 122 Chapter 08: Secondary Storage Devices Slide 5/117
Computer Fundamentals: Pradeep K. Sinha & Priti Sinha
Classification of Commonly Used Secondary
Storage Devices

Ref. Page 123 Chapter 08: Secondary Storage Devices Slide 6/117
Computer Fundamentals: Pradeep K. Sinha & Priti Sinha

Sequential and Direct-


Access Storage Devices

Chapter 08: Secondary Storage Devices Slide 7/117


Computer Fundamentals: Pradeep K. Sinha & Priti Sinha

Sequential-access Storage Devices


 Arrival at the desired storage location may be preceded
by sequencing through other locations
 Data can only be retrieved in the same sequence in
which it is stored
 Access time varies according to the storage location of
the information being accessed
 Suitable for sequential processing applications where
most, if not all, of the data records need to be
processed one after another
 Magnetic tape is a typical example of such a storage
device

Ref. Page 123 Chapter 08: Secondary Storage Devices Slide 8/117
Computer Fundamentals: Pradeep K. Sinha & Priti Sinha

Direct-access Storage Devices

 Devices where any storage location may be selected


and accessed at random
 Permits access to individual information in a more
direct or immediate manner
 Approximately equal access time is required for
accessing information from any storage location
 Suitable for direct processing applications such as on-
line ticket booking systems, on-line banking systems
 Magnetic, optical, and magneto-optical disks are typical
examples of such a storage device

Ref. Page 123 Chapter 08: Secondary Storage Devices Slide 9/117
Computer Fundamentals: Pradeep K. Sinha & Priti Sinha

Magnetic Tapes

Chapter 08: Secondary Storage Devices Slide 10/117


Computer Fundamentals: Pradeep K. Sinha & Priti Sinha

Magnetic Tape Basics


 Commonly used sequential-access secondary storage
device
 Physically, the tape medium is a plastic ribbon, which is
usually ½ inch or ¼ inch wide and 50 to 2400 feet long
 Plastic ribbon is coated with a magnetizable recording
material such as iron-oxide or chromium dioxide
 Data are recorded on the tape in the form of tiny
invisible magnetized and non-magnetized spots
(representing 1s and 0s) on its coated surface
 Tape ribbon is stored in reels or a small cartridge or
cassette

Ref. Page 124 Chapter 08: Secondary Storage Devices Slide 11/117
Computer Fundamentals: Pradeep K. Sinha & Priti Sinha
Magnetic Tape - Storage Organization
(Example 1)

Characters for
Track/channel A frame
corresponding codes
numbers

0 1 2 3 4 5 6 7 8 9 A B C D E F G H I
Parity bit 7
6 Each vertical
Zone line represents
5
a binary 1 bit
4
Numeric 3
2
1

Illustrates the concepts of frames, tracks, parity bit, and character-by-character data
storage

Ref. Page 125 Chapter 08: Secondary Storage Devices Slide 12/117
Computer Fundamentals: Pradeep K. Sinha & Priti Sinha
Magnetic Tape - Storage Organization
(Example 2)
Track/channel A frame for Characters for
numbers each character corresponding codes

0 1 2 3 4 5 6 7 8 9 A B C

8’s digit 9

2’s digit 8
Each vertical
Added zone 7 line represents
Track a binary 1 bit
Added zone 6
representation
Zone 5

Parity bit 4

Zone 3

Unit’s digit 2
4’s digit 1

Illustrates the concepts of frames, tracks, parity bit, and character-by-character data storage

Ref. Page 125 Chapter 08: Secondary Storage Devices Slide 13/117
Computer Fundamentals: Pradeep K. Sinha & Priti Sinha

Magnetic Tape Storage Capacity


 Storage capacity of a tape =
Data recording density x Length
 Data recording density is the amount of data that can be
stored on a given length of tape. It is measured in bytes
per inch (bpi)
 Tape density varies from 800 bpi in older systems to
77,000 bpi in some of the modern systems
 Actual storage capacity of a tape may be anywhere from
35% to 70% of its total storage capacity, depending on
the storage organization used

Ref. Page 126 Chapter 08: Secondary Storage Devices Slide 14/117
Computer Fundamentals: Pradeep K. Sinha & Priti Sinha

Magnetic Tape – Data Transfer Rate

 Refers to characters/second that can be transmitted to


the memory from the tape
 Transfer rate measurement unit is bytes/second (bps)
 Value depends on the data recording density and the
speed with which the tape travels under the read/write
head
 A typical value of data transfer rate is 7.7 MB/second

Ref. Page 126 Chapter 08: Secondary Storage Devices Slide 15/117
Computer Fundamentals: Pradeep K. Sinha & Priti Sinha

Magnetic Tape – Tape Drive


 Used for writing/reading of data to/from a magnetic
tape ribbon
 Different for tape reels, cartridges, and cassettes
 Has read/write heads for reading/writing of data on
tape
 A magnetic tape reel/cartridge/cassette has to be first
loaded on a tape drive for reading/writing of data on it
 When processing is complete, the tape is removed
from the tape drive for off-line storage

Ref. Page 126 Chapter 08: Secondary Storage Devices Slide 16/117
Computer Fundamentals: Pradeep K. Sinha & Priti Sinha

Magnetic Tape – Tape Controller


 Tape drive is connected to and controlled by a tape
controller that interprets the commands for operating the
tape drive

 A typical set of commands supported by a tape controller


are:
Read reads one block of data

Write writes one block of data

Write tape header label used to update the contents of tape header label

Erase tape erases the data recorded on a tape

Back space one block rewinds the tape to the beginning of previous block

(Continued on next slide)

Ref. Page 126 Chapter 08: Secondary Storage Devices Slide 17/117
Computer Fundamentals: Pradeep K. Sinha & Priti Sinha

Magnetic Tape – Tape Controller

Forward space one block forwards the tape to the beginning


of next block

Forward space one file forwards the tape to the beginning


of next file

Rewind fully rewinds the tape

Unload releases the tape drive’s grip so


that the tape spool can be
unmounted from the tape drive

Ref. Page 126 Chapter 08: Secondary Storage Devices Slide 18/117
Computer Fundamentals: Pradeep K. Sinha & Priti Sinha

Types of Magnetic Tape

 ½-inch tape reel

 ½-inch tape cartridge

 ¼-inch streamer tape

 4-mm digital audio tape (DAT)

Ref. Page 126 Chapter 08: Secondary Storage Devices Slide 19/117
Computer Fundamentals: Pradeep K. Sinha & Priti Sinha

Half-inch Tape Reel


 Uses ½ inch wide tape ribbon stored on a tape reel
 Uses parallel representation method of storing data, in
which data are read/written a byte at a time
 Uses a read/write head assembly that has one
read/write head for each track
 Commonly used as archival storage for off-line storage
of data and for exchange of data and programs
between organizations
 Fast getting replaced by tape cartridge, streamer tape,
and digital audio tape they are more compact, cheaper
and easier to handle

Ref. Page 127 Chapter 08: Secondary Storage Devices Slide 20/117
Computer Fundamentals: Pradeep K. Sinha & Priti Sinha

Half-inch Tape Reel

Ref. Page 127 Chapter 08: Secondary Storage Devices Slide 21/117
Computer Fundamentals: Pradeep K. Sinha & Priti Sinha

Tape Drive of Half-inch Tape Reel


Supply reel Magnetic tape Take-up reel

Read/write
head assembly

Vacuum
columns

Tape loops
varying in length

Ref. Page 127 Chapter 08: Secondary Storage Devices Slide 22/117
Computer Fundamentals: Pradeep K. Sinha & Priti Sinha

Half-inch Tape Cartridge


 Uses ½ inch wide tape ribbon sealed in a cartridge
 Has 36 tracks, as opposed to 9 tracks for most half-inch
tape reels
 Stores data using parallel representation. Hence, 4 bytes
of data are stored across the width of the tape. This
enables more bytes of data to be stored on the same
length of tape
 Tape drive reads/writes on the top half of the tape in one
direction and on the bottom half in the other direction

Ref. Page 127 Chapter 08: Secondary Storage Devices Slide 23/117
Computer Fundamentals: Pradeep K. Sinha & Priti Sinha

Half-inch Tape Cartridge

Ref. Page 127 Chapter 08: Secondary Storage Devices Slide 24/117
Computer Fundamentals: Pradeep K. Sinha & Priti Sinha

Quarter-inch Streamer Tape

 Uses ¼ inch wide tape ribbon sealed in a cartridge


 Uses serial representation of data recording (data bits
are aligned in a row one after another in tracks)
 Can have from 4 to 30 tracks, depending on the tape
drive
 Depending on the tape drive, the read/write head
reads/writes data on one/two/four tracks at a time
 Eliminates the need for the start/stop operation of
traditional tape drives

(Continued on next slide)

Ref. Page 128 Chapter 08: Secondary Storage Devices Slide 25/117
Computer Fundamentals: Pradeep K. Sinha & Priti Sinha

Quarter-inch Streamer Tape


 Can read/write data more efficiently than the
traditional tape drives because there is no start/stop
mechanism
 Make more efficient utilization of tape storage area
than traditional tape drives because IBGs are not
needed
 The standard data formats used in these tapes is
known as the QIC standard

Ref. Page 128 Chapter 08: Secondary Storage Devices Slide 26/117
Computer Fundamentals: Pradeep K. Sinha & Priti Sinha

Quarter-inch Streamer Tape (Example)

Recording area Recording area


begins here ends here
Tracks
1 1 0 1 1 0 0 1 1 1 0 1 0.
2 ..
0 0 1 0 1 0 0 1 1 1 0 1...
3 Unused Unused
4 portion portion
of the of the
5 tape tape
6

7
8

Ref. Page 128 Chapter 08: Secondary Storage Devices Slide 27/117
Computer Fundamentals: Pradeep K. Sinha & Priti Sinha

4mm Digital Audio Tape (DAT)


 Uses 4mm wide tape ribbon sealed in a cartridge
 Has very high data recording density
 Uses a tape drive that uses helical scan technique for
data recording, in which two read heads and two write
heads are built into a small wheel
 DAT drives use a data recording format called Digital
Data Storage (DDS), which provides three levels of
error-correcting code
 Typical capacity of DAT cartridges varies from
4 GB to 14 GB

Ref. Page 128 Chapter 08: Secondary Storage Devices Slide 28/117
Computer Fundamentals: Pradeep K. Sinha & Priti Sinha
The Helical Scan Techniques
Used in DAT Drives

Write head B
Read head A
Spinning
Read head B
helical
scan

Write head A

Moving tape

Shaft

Ref. Page 128 Chapter 08: Secondary Storage Devices Slide 29/117
Computer Fundamentals: Pradeep K. Sinha & Priti Sinha

Advantages of Magnetic Tapes


 Storage capacity is virtually unlimited because as many
tapes as required can be used for storing very large
data sets
 Cost per bit of storage is very low for magnetic tapes.
 Tapes can be erased and reused many times
 Tape reels and cartridges are compact and light in
weight
 Easy to handle and store.
 Very large amount of data can be stored in a small
storage space

(Continued on next slide)

Ref. Page 128 Chapter 08: Secondary Storage Devices Slide 30/117
Computer Fundamentals: Pradeep K. Sinha & Priti Sinha

Advantages of Magnetic Tapes

 Compact size and light weight


 Magnetic tape reels and cartridges are also easily
portable from one place to another
 Often used for transferring data and programs from
one computer to another that are not linked together

Ref. Page 128 Chapter 08: Secondary Storage Devices Slide 31/117
Computer Fundamentals: Pradeep K. Sinha & Priti Sinha

Limitations of Magnetic Tapes


 Due to their sequential access nature, they are not
suitable for storage of those data that frequently
require to be accessed randomly
 Must be stored in a dust-free environment because
specks of dust can cause tape-reading errors
 Must be stored in an environment with properly
controlled temperature and humidity levels
 Tape ribbon may get twisted due to warping, resulting
in loss of stored data
 Should be properly labeled so that some useful data
stored on a particular tape is not erased by mistake

Ref. Page 129 Chapter 08: Secondary Storage Devices Slide 32/117
Computer Fundamentals: Pradeep K. Sinha & Priti Sinha

Uses of Magnetic Tapes

 For applications that are based on sequential data


processing
 Backing up of data for off-line storage
 Archiving of infrequently used data
 Transferring of data from one computer to another that
are not linked together
 As a distribution media for software by vendors

Ref. Page 129 Chapter 08: Secondary Storage Devices Slide 33/117
Computer Fundamentals: Pradeep K. Sinha & Priti Sinha

Uses of Magnetic Tapes

Inventory New inventory New inventory


master file master file master file

Processing Next
processing

Transaction file New transaction file

Illustrating the use of tapes in a sequential application.

Ref. Page 129 Chapter 08: Secondary Storage Devices Slide 34/117
Computer Fundamentals: Pradeep K. Sinha & Priti Sinha

Magnetic Disks

Chapter 08: Secondary Storage Devices Slide 35/117


Computer Fundamentals: Pradeep K. Sinha & Priti Sinha

Magnetic Disk - Basics


 Commonly used direct-access secondary storage device.
 Physically, a magnetic disk is a thin, circular
plate/platter made of metal or plastic that is usually
coated on both sides with a magnetizable recording
material such as iron-oxide
 Data are recorded on the disk in the form of tiny
invisible magnetized and non-magnetized spots
(representing 1s and 0s) on the coated surfaces of the
disk
 The disk is stored in a specially designed protective
envelope or cartridge, or several of them are stacked
together in a sealed, contamination-free container

Ref. Page 129 Chapter 08: Secondary Storage Devices Slide 36/117
Computer Fundamentals: Pradeep K. Sinha & Priti Sinha
Magnetic Disk – Storage Organization
Illustrates the Concept of Tracks

200  A disk’s surface is divided into


Track 000
Tracks a number of invisible
concentric circles called tracks

 The tracks are numbered


consecutively from outermost
to innermost starting from
zero
… Track …  The number of tracks on a
199 disk may be as few as 40 on
small, low-capacity disks, to
several thousand on large,
high-capacity disks

Ref. Page 130 Chapter 08: Secondary Storage Devices Slide 37/117
Computer Fundamentals: Pradeep K. Sinha & Priti Sinha
Magnetic Disk – Storage Organization
Illustrates the Concept of Sectors

A sector

 Each track of a disk is


subdivided into sectors

 There are 8 or more


sectors per track

 A sector typically contains


512 bytes

 Disk drives are designed to


read/write only whole
sectors at a time

Ref. Page 130 Chapter 08: Secondary Storage Devices Slide 38/117
Computer Fundamentals: Pradeep K. Sinha & Priti Sinha

Disk Pack
 Data is accessed from a disk by specifying its disk address

 It is comprised of sector number, track number, and surface


number

 Operating systems combine two or more sectors to form a cluster

 In this case, the smallest unit of data access from a disk is a


cluster, instead of a sector

 Read/write operations read/write a whole cluster at a time

 Multiple disks are stacked together as a disk pack

 Disk pack is sealed and mounted on a disk drive consisting of a


motor to rotate the disk pack about its axis

 Disk drive has an access arms assembly having separate


read/write heads for each surface of the disk pack

Ref. Page 130 Chapter 08: Secondary Storage Devices Slide 39/117
Computer Fundamentals: Pradeep K. Sinha & Priti Sinha

Cylinder-Head-Sector (CHS)

 Corresponding tracks on all recording surfaces of a disk


pack together form a cylinder

 Addressing scheme is called CHS (Cylinder-Head-Sector)


addressing

 It is also known as disk geometry

Ref. Page 131 Chapter 08: Secondary Storage Devices Slide 40/117
Computer Fundamentals: Pradeep K. Sinha & Priti Sinha
Magnetic Disk – Storage Organization
(Illustrates the Concept of Cylinder)

Upper surface
not used
Read/Write head
Surface - 0
Surface - 1
Direction of movement of
access arms assembly
Surface - 2
Cylinder
Surface - 3

Surface - 4 Access arms assembly


Surface - 5

Lower surface
not used Central shaft

No. of disk platters = 4, No. of usable surfaces = 6. A set of corresponding


tracks on all the 6 surfaces is called a cylinder.

Ref. Page 131 Chapter 08: Secondary Storage Devices Slide 41/117
Computer Fundamentals: Pradeep K. Sinha & Priti Sinha

Magnetic Disk – Storage Capacity

Storage capacity of a disk system = Number of recording surfaces


 Number of tracks per surface
 Number of sectors per track
 Number of bytes per sector

Ref. Page 132 Chapter 08: Secondary Storage Devices Slide 42/117
Computer Fundamentals: Pradeep K. Sinha & Priti Sinha

Access Mechanism

 Data is recorded on the tracks of a spinning disk surface and read


from the surface by one or more read/write heads

 Read/write heads are mounted on an access arms assembly

 Access arms assembly moves in and out

 Read/write heads move horizontally across the surfaces of the


disks

 In case of a disk pack all heads move together

 Read/write heads are of flying type

 They do not have direct contact with disk surfaces

Ref. Page 132 Chapter 08: Secondary Storage Devices Slide 43/117
Computer Fundamentals: Pradeep K. Sinha & Priti Sinha

Magnetic Disk Pack – Access Mechanism

One read/write
head per surface Central shaft

Direction of movement of
access arms assembly .
. Disk platters
.

Access arms
assembly

Vertical cross section of a disk system. There is one read/write head per
recording surface

Ref. Page 132 Chapter 08: Secondary Storage Devices Slide 44/117
Computer Fundamentals: Pradeep K. Sinha & Priti Sinha

Magnetic Disk – Access Time


 Disk access time is the interval between the instant a
computer makes a request for transfer of data from a
disk system to the primary storage and the instant this
operation is completed

 Disk access time depends on the following three


parameters:

– Seek Time: It is the time required to position the


read/write head over the desired track, as soon as
a read/write command is received by the disk unit

– Latency: It is the time required to spin the desired


sector under the read/write head, once the
read/write head is positioned on the desired track

Ref. Page 133 Chapter 08: Secondary Storage Devices Slide 45/117
Computer Fundamentals: Pradeep K. Sinha & Priti Sinha

Magnetic Disk – Access Time


– Transfer Rate: It is the rate at which data are
read/written to the disk, once the read/write head
is positioned over the desired sector

 As the transfer rate is negligible as compared to seek


time and latency,

Average access time

= Average seek time + Average latency

Ref. Page 133 Chapter 08: Secondary Storage Devices Slide 46/117
Computer Fundamentals: Pradeep K. Sinha & Priti Sinha

Disk Formatting
 Process of preparing a new disk by the computer
system in which the disk is to be used.
 For this, a new (unformatted) disk is inserted in the disk
drive of the computer system and the disk formatting
command is initiated
 Low-level disk formatting
 Disk drive’s read/write head lays down a magnetic
pattern on the disk’s surface
 Enables the disk drive to organize and store the
data in the data organization defined for the disk
drive of the computer

(Continued on next slide)

Ref. Page 134 Chapter 08: Secondary Storage Devices Slide 47/117
Computer Fundamentals: Pradeep K. Sinha & Priti Sinha

Disk Formatting
 OS-level disk formatting
 Creates the File Allocation Table (FAT) that is a
table with the sector and track locations of data
 Leaves sufficient space for FAT to grow
 Scans and marks bad sectors
 One of the basic tasks handled by the computer’s
operating system
 Enables the use of disks manufactured by third party
vendors into one’s own computer system

Ref. Page 134 Chapter 08: Secondary Storage Devices Slide 48/117
Computer Fundamentals: Pradeep K. Sinha & Priti Sinha

Magnetic Disk – Disk Drive

 Unit used for reading/writing of data on/from a


magnetic disk

 Contains all the mechanical, electrical and electronic


components for holding one or more disks and for
reading or writing of information on to it

(Continued on next slide)

Ref. Page 134 Chapter 08: Secondary Storage Devices Slide 49/117
Computer Fundamentals: Pradeep K. Sinha & Priti Sinha

Magnetic Disk – Disk Drive


 Although disk drives vary greatly in their shape, size
and disk formatting pattern, they can be broadly
classified into two types:

– Those with interchangeable magnetic disks,


which allow the loading and unloading of
magnetic disks as and when they are needed for
reading/writing of data on to them

– Those with fixed magnetic disks, which come


along with a set of permanently fixed disks. The
disks are not removable from their disk drives

Ref. Page 134 Chapter 08: Secondary Storage Devices Slide 50/117
Computer Fundamentals: Pradeep K. Sinha & Priti Sinha

Magnetic Disk – Disk Controller

 Disk drive is connected to and controlled by a disk


controller, which interprets the commands for
operating the disk drive
 Typically supports only read and write commands,
which need disk address (surface number,
cylinder/track number, and sector number) as
parameters
 Connected to and controls more than one disk drive, in
which case the disk drive number is also needed as a
parameters of read and write commands

Ref. Page 135 Chapter 08: Secondary Storage Devices Slide 51/117
Computer Fundamentals: Pradeep K. Sinha & Priti Sinha

Types of Magnetic Disks

Magnetic Disks

Zip/Bernoulli Disks Disk Packs Winchester Disks

Ref. Page 135 Chapter 08: Secondary Storage Devices Slide 52/117
Computer Fundamentals: Pradeep K. Sinha & Priti Sinha

Hard Disks

 Round, flat piece of rigid metal (frequently aluminium)


disks coated with magnetic oxide
 Come in many sizes, ranging from 1 to 14-inch diameter.
 Depending on how they are packaged, hard disks are of
three types:
 Zip/Bernoulli disks
 Disk packs
 Winchester disks
 Primary on-line secondary storage device for most
computer systems today

Ref. Page 135 Chapter 08: Secondary Storage Devices Slide 53/117
Computer Fundamentals: Pradeep K. Sinha & Priti Sinha

Zip/Bernoulli Disks
 Uses a single hard disk platter encased in a plastic
cartridge
 Disk drives may be portable or fixed type
 Fixed type is part of the computer system, permanently
connected to it
 Portable type can be carried to a computer system,
connected to it for the duration of use, and then can be
disconnected and taken away when the work is done
 Zip disks can be easily inserted/removed from a zip drive
just as we insert/remove floppy disks in a floppy disk
drive

Ref. Page 135 Chapter 08: Secondary Storage Devices Slide 54/117
Computer Fundamentals: Pradeep K. Sinha & Priti Sinha

Disk Packs
 Uses multiple (two or more) hard disk platters
mounted on a single central shaft
 Disk drives have a separate read/write head for each
usable disk surface (the upper surface of the top-most
disk and the lower surface of the bottom most disk is
not used)
 Disks are of removable/interchangeable type in the
sense that they have to be mounted on the disk drive
before they can be used, and can be removed and
kept off-line when not in use

Ref. Page 135 Chapter 08: Secondary Storage Devices Slide 55/117
Computer Fundamentals: Pradeep K. Sinha & Priti Sinha

Winchester Disks

 Uses multiple (two or more) hard disk platters


mounted on a single central shaft

 Hard disk platters and the disk drive are sealed


together in a contamination-free container and cannot
be separated from each other

(Continued on next slide)

Ref. Page 136 Chapter 08: Secondary Storage Devices Slide 56/117
Computer Fundamentals: Pradeep K. Sinha & Priti Sinha

Winchester Disks

 For the same number of disks, Winchester disks have


larger storage capacity than disk packs because:

– All the surfaces of all disks are used for data


recording

They employ much greater precision of data recording,


resulting in greater data recording density

 Named after the 30-30 Winchester rifle because the early


Winchester disk systems had two 30-MB disks sealed
together with the disk drive

Ref. Page 136 Chapter 08: Secondary Storage Devices Slide 57/117
Computer Fundamentals: Pradeep K. Sinha & Priti Sinha

Advantages of Magnetic Disks

 More suitable than magnetic tapes for a wider range of


applications because they support direct access of data
 Random access property enables them to be used
simultaneously by multiple users as a shared device. A
tape is not suitable for such type of usage due to its
sequential-access property
 Suitable for both on-line and off-line storage of data

(Continued on next slide)

Ref. Page 136 Chapter 08: Secondary Storage Devices Slide 58/117
Computer Fundamentals: Pradeep K. Sinha & Priti Sinha

Advantages of Magnetic Disks

 Except for the fixed type Winchester disks, the storage


capacity of other magnetic disks is virtually unlimited
as many disks can be used for storing very large data
sets
 Due to their low cost and high data recording densities,
the cost per bit of storage is low for magnetic disks.
 An additional cost benefit is that magnetic disks can be
erased and reused many times
 Floppy disks and zip disks are compact and light in
weight. Hence they are easy to handle and store.
 Very large amount of data can be stored in a small
storage space
(Continued on next slide)

Ref. Page 136 Chapter 08: Secondary Storage Devices Slide 59/117
Computer Fundamentals: Pradeep K. Sinha & Priti Sinha

Advantages of Magnetic Disks

 Due to their compact size and light weight, floppy disks


and zip disks are also easily portable from one place to
another
 They are often used for transferring data and programs
from one computer to another, which are not linked
together
 Any information desired from a disk storage can be
accessed in a few milliseconds because it is a direct
access storage device

(Continued on next slide)

Ref. Page 136 Chapter 08: Secondary Storage Devices Slide 60/117
Computer Fundamentals: Pradeep K. Sinha & Priti Sinha

Advantages of Magnetic Disks

 Data transfer rate for a magnetic disk system is


normally higher than a tape system
 Magnetic disks are less vulnerable to data corruption
due to careless handling or unfavorable temperature
and humidity conditions than magnetic tapes

Ref. Page 136 Chapter 08: Secondary Storage Devices Slide 61/117
Computer Fundamentals: Pradeep K. Sinha & Priti Sinha

Limitations of Magnetic Disks

 Although used for both random processing and


sequential processing of data, for applications of the
latter type, it may be less efficient than magnetic
tapes
 More difficult to maintain the security of information
stored on shared, on-line secondary storage devices,
as compared to magnetic tapes or other types of
magnetic disks

(Continued on next slide)

Ref. Page 137 Chapter 08: Secondary Storage Devices Slide 62/117
Computer Fundamentals: Pradeep K. Sinha & Priti Sinha

Limitations of Magnetic Disks

 For Winchester disks, a disk crash or drive failure often


results in loss of entire stored data. It is not easy to
recover the lost data. Suitable backup procedures are
suggested for data stored on Winchester disks
 Some types of magnetic disks, such as disk packs and
Winchester disks, are not so easily portable like
magnetic tapes
 On a cost-per-bit basis, the cost of magnetic disks is
low, but the cost of magnetic tapes is even lower

(Continued on next slide)

Ref. Page 137 Chapter 08: Secondary Storage Devices Slide 63/117
Computer Fundamentals: Pradeep K. Sinha & Priti Sinha

Limitations of Magnetic Disks

 Must be stored in a dust-free environment


 Floppy disks, zip disks and disk packs should be
labeled properly to prevent erasure of useful data by
mistake

Ref. Page 137 Chapter 08: Secondary Storage Devices Slide 64/117
Computer Fundamentals: Pradeep K. Sinha & Priti Sinha

Uses of Magnetic Disks

 For applications that are based on random data


processing
 As a shared on-line secondary storage device.
Winchester disks and disk packs are often used for
this purpose
 As a backup device for off-line storage of data. Floppy
disks, zip disks, and disk packs are often used for this
purpose

(Continued on next slide)

Ref. Page 137 Chapter 08: Secondary Storage Devices Slide 65/117
Computer Fundamentals: Pradeep K. Sinha & Priti Sinha

Uses of Magnetic Disks

 Archiving of data not used frequently, but may be


used once in a while. Floppy disks, zip disks, and
disk packs are often used for this purpose
 Transferring of data and programs from one
computer to another that are not linked together. Zip
disks are often used for this purpose

Ref. Page 137 Chapter 08: Secondary Storage Devices Slide 66/117
Computer Fundamentals: Pradeep K. Sinha & Priti Sinha

Optical Disks

Chapter 08: Secondary Storage Devices Slide 67/117


Computer Fundamentals: Pradeep K. Sinha & Priti Sinha

Optical Disk – Basics


 Consists of a circular disk, which is coated with a thin
metal or some other material that is highly reflective
 Laser beam technology is used for recording/reading
of data on the disk
 Also known as laser disk / optical laser disk, due to
the use of laser beam technology
 Proved to be a promising random access medium for
high capacity secondary storage because it can store
extremely large amounts of data in a limited space

Ref. Page 137 Chapter 08: Secondary Storage Devices Slide 68/117
Computer Fundamentals: Pradeep K. Sinha & Priti Sinha

Optical Disk – Storage Organization

 Has one long spiral track, which starts at the outer edge
and spirals inward to the center
 Track is divided into equal size sectors

(a) Track pattern on an optical disk (b) Track pattern on a magnetic disk

Difference in track patterns on optical and magnetic disks.

Ref. Page 138 Chapter 08: Secondary Storage Devices Slide 69/117
Computer Fundamentals: Pradeep K. Sinha & Priti Sinha

Optical Disk – Storage Capacity

Storage capacity of an optical disk

= Number of sectors
 Number of bytes per sector

The most popular optical disk uses a disk of 5.25 inch


diameter with formatted storage capacity of around 650
Megabytes

Ref. Page 139 Chapter 08: Secondary Storage Devices Slide 70/117
Computer Fundamentals: Pradeep K. Sinha & Priti Sinha

Optical Disk – Access Mechanism

Laser Laser
beam beam
source source

Prism Sensor Prism Sensor

Laser beam is
scattered by a pit
Laser beam is
reflected by a land

Land Land Land


Pit Pit Pit

Ref. Page 139 Chapter 08: Secondary Storage Devices Slide 71/117
Computer Fundamentals: Pradeep K. Sinha & Priti Sinha

Optical Disk – Access Time


 With optical disks, each sector has the same length
regardless of whether it is located near or away from
the disk’s center
 Rotation speed of the disk must vary inversely with
the radius. Hence, optical disk drives use a constant
linear velocity (CLV) encoding scheme
 Leads to slower data access time (larger access time)
for optical disks than magnetic disks
 Access times for optical disks are typically in the
range of 100 to 300 milliseconds and that of hard
disks are in the range of 10 to 30 milliseconds

Ref. Page 140 Chapter 08: Secondary Storage Devices Slide 72/117
Computer Fundamentals: Pradeep K. Sinha & Priti Sinha

Optical Disk Drive

 Uses laser beam technology for reading/writing of data


 Has no mechanical read/write access arm
 Uses a constant linear velocity (CLV) encoding scheme,
in which the rotational speed of the disk varies inversely
with the radius

Ref. Page 139 Chapter 08: Secondary Storage Devices Slide 73/117
Computer Fundamentals: Pradeep K. Sinha & Priti Sinha

Optical Disk Drive

Volume control button used


when the drive is used to play
Light indicator an audio CD

Optical disk

Is placed on top
Headphone socket
of this groove
enables a user to
plug-in headphones Tray Direction
to recorded sound eject of movement
when the drive is button of the tray Optical disk tray
used to play audio
CDs.

Ref. Page 140 Chapter 08: Secondary Storage Devices Slide 74/117
Computer Fundamentals: Pradeep K. Sinha & Priti Sinha

Types of Optical Disks


The types of optical disks in use today are:

CD-ROM

 Stands for Compact Disk-Read Only Memory


 Packaged as shiny, silver color metal disk of 5¼
inch (12cm) diameter, having a storage capacity of
about 650 Megabytes
 Disks come pre-recorded and the information
stored on them cannot be altered
 Pre-stamped (pre-recorded) by their suppliers, by a
process called mastering

(Continued on next slide)

Ref. Page 140 Chapter 08: Secondary Storage Devices Slide 75/117
Computer Fundamentals: Pradeep K. Sinha & Priti Sinha

Types of Optical Disks


 Provide an excellent medium to distribute large
amounts of data in electronic dorm at low cost.
 A single CD-ROM disk can hold a complete
encyclopedia, or a dictionary, or a world atlas, or
biographies of great people, etc
 Used for distribution of electronic version of
conference proceedings, journals, magazines,
books, and multimedia applications such as video
games
 Used by software vendors for distribution of
software to their customers

(Continued on next slide)

Ref. Page 141 Chapter 08: Secondary Storage Devices Slide 76/117
Computer Fundamentals: Pradeep K. Sinha & Priti Sinha

Types of Optical Disks


WORM Disk / CD-Recordable (CD-R)

 Stands for Write Once Read Many. Data can be written


only once on them, but can be read many times
 Same as CD-ROM and has same storage capacity
 Allow users to create their own CD-ROM disks by using
a CD-recordable (CD-R) drive that can be attached to
a computer as a regular peripheral device
 Data to be recorded can be written on its surface in
multiple recording sessions

(Continued on next slide)

Ref. Page 141 Chapter 08: Secondary Storage Devices Slide 77/117
Computer Fundamentals: Pradeep K. Sinha & Priti Sinha

Types of Optical Disks


 Sessions after the first one are always additive
and cannot alter the etched/burned information of
earlier sessions
 Information recorded on them can be read by any
ordinary CD-ROM drive
 They are used for data archiving and for making a
permanent record of data. For example, many
banks use them for storing their daily transactions

(Continued on next slide)

Ref. Page 142 Chapter 08: Secondary Storage Devices Slide 78/117
Computer Fundamentals: Pradeep K. Sinha & Priti Sinha

Types of Optical Disks


CD-Read/Write (CD-RW)

 Same as CD-R and has same storage capacity


 Allow users to create their own CD-ROM disks by
using a CD-recordable (CD-R) drive that can be
attached to a computer as a regular peripheral
device
 Data to be recorded can be written on its surface in
multiple recording sessions
 Made of metallic alloy layer whose chemical
properties are changed during burn and erase
 Can be erased and written afresh
(Continued on next slide)

Ref. Page 141 Chapter 08: Secondary Storage Devices Slide 79/117
Computer Fundamentals: Pradeep K. Sinha & Priti Sinha

Types of Optical Disks


 Digital Video (or Versatile) Disk (DVD)
 DVD is a standard format for distribution and interchange of
digital content
 Pits are about 4½ times as dense on a DVD as on a CD
 Stores about seven times more data per side
 Greater density is due to a more efficient data modulation
scheme and error correction method
 DVD follows Eight-to-Fourteen Modulation Plus (EFMPlus)
encoding
 Two variants of DVD – single-layer disk and double-layer
disk
 Single-layer disk has storage capacity of 4.7 GB
 Double-layer disk has storage capacity of 8.5 GB (Continued on next slide)

Ref. Page 142 Chapter 08: Secondary Storage Devices Slide 80/117
Computer Fundamentals: Pradeep K. Sinha & Priti Sinha

Types of Optical Disks

 Physical layer specification defines following types of physical


media:
 DVD-ROM: Used for mass distribution of pre-recorded
software programs and multimedia
 DVD-RAM: Used for general read-and-write applications
 DVD-R: Used for low-cost, write-once recordable media
 DVD-RW: Rewritable version of DVD-R

(Continued on next slide)

Ref. Page 142 Chapter 08: Secondary Storage Devices Slide 81/117
Computer Fundamentals: Pradeep K. Sinha & Priti Sinha

Types of Optical Disks

 Logical layer specification defines recording formats for video


and audio data
 DVD-video
 Now the most dominant movie storage format
 Allows storage of video in 4:3 or 16:9 aspect ratio in
MPEG-2 video format
 Audio is usually Dolby Digital (AC-3) or Digital Theater
System (DTS)
 Can be either monaural or 5.1 surround sound
 It has multiple selectable language soundtracks and
subtitles

(Continued on next slide)

Ref. Page 143 Chapter 08: Secondary Storage Devices Slide 82/117
Computer Fundamentals: Pradeep K. Sinha & Priti Sinha

Types of Optical Disks

 DVD-audio
 Offers multiple choices of sampling rate and number of bits
per sample
 Specification also supports up to six channels of
multichannel
 Surround sound with 24-bit sampling at a 48 KHz rate
 Provision for visual menus, still images, and video to
accompany the audio program

Ref. Page 143 Chapter 08: Secondary Storage Devices Slide 83/117
Computer Fundamentals: Pradeep K. Sinha & Priti Sinha

Advantages of Optical Disks


 Cost-per-bit of storage for optical disks is very low
 Use of a single spiral track makes optical disks an ideal
storage medium for reading large blocks of sequential data
 Optical disk drives do not have any mechanical read/write
heads
 Optical disks have data storage life in excess of 30 years
 Data once stored on CD-ROM/WROM disks becomes
permanent, there is no danger of losing stored data
 Due to their compact size and lightweight, optical disks are
easy to handle
 Can use a computer having a CD-ROM drive, a sound card,
and speakers as a music system
 Can use a computer having a DVD drive to play DVDs

Ref. Page 143 Chapter 08: Secondary Storage Devices Slide 84/117
Computer Fundamentals: Pradeep K. Sinha & Priti Sinha

Limitations of Optical Disks

 Data access speed of optical disks is slower than that of


magnetic disks
 Optical disks require more complicated drive mechanism
 Optical disk is prone to scratches, dust, sticky prints etc.
while handling
 Optical disks must be labeled properly

Ref. Page 143 Chapter 08: Secondary Storage Devices Slide 85/117
Computer Fundamentals: Pradeep K. Sinha & Priti Sinha

Uses of Optical Disks


 For distributing large amounts of data at low cost
 For distribution of electronic version of conference
proceedings, journals, magazines, books, product catalogs,
etc.
 For distribution of audio such as songs
 For distribution of new or upgraded versions of software
products
 For storage and distribution of wide variety of multimedia
applications
 For archiving of data not used frequently
 To make permanent storage of proprietary information
 DVDs have become a popular medium for distribution of
movies

Ref. Page 143 Chapter 08: Secondary Storage Devices Slide 86/117
Computer Fundamentals: Pradeep K. Sinha & Priti Sinha

Memory Storage Devices

Chapter 08: Secondary Storage Devices Slide 87/117


Computer Fundamentals: Pradeep K. Sinha & Priti Sinha

Memory Storage Devices

 A new breed of electronic secondary storage devices

 They are faster and more reliable than conventional


secondary storage devices because they do not use any
mechanical component

 Some popular ones are:

 Solid State Drive (SSD)


 Flash Drive (Pen Drive)
 Memory Card (SD/MMC)

Ref. Page 144 Chapter 08: Secondary Storage Devices Slide 88/117
Computer Fundamentals: Pradeep K. Sinha & Priti Sinha

Solid State Drive (SSD)

 Is a new alternative to Hard Disk Drive (HDD) based


secondary storage in computer systems

 It consists of interconnected flash memory chips

 It is built entirely out of semiconductors (hence the name


solid state) and does not have any moving parts

 It is more expensive than HDD of same capacity, but is more


reliable, rugged, compact and faster in data access speed

Ref. Page 144 Chapter 08: Secondary Storage Devices Slide 89/117
Computer Fundamentals: Pradeep K. Sinha & Priti Sinha

Inside View of HDD and SSD

(a) Hard Disk Drive (HDD) (b) Solid State Drive (SSD)

Figure 8.16. Inside view of HDD and SSD. When packaged in an enclosure, both may
look similar from outside, but internally their design is very different.

Ref. Page 145 Chapter 08: Secondary Storage Devices Slide 90/117
Computer Fundamentals: Pradeep K. Sinha & Priti Sinha

Memory Storage Devices


Flash Drive (Pen Drive)
 Flash drive is a compact device of the size of a pen
 Comes in various shapes and stylish designs
 May have different added features
 It is a plug-and-play device
 Plugs into a USB (Universal Serial Bus) port
 Computer detects it automatically as a removable drive
 Once done, it can be simply plugged out of the USB port
 Flash drive does not require any battery, cable, or software
 It is the most preferred external data storage

Ref. Page 146 Chapter 08: Secondary Storage Devices Slide 91/117
Computer Fundamentals: Pradeep K. Sinha & Priti Sinha

Memory Storage Devices

 It is based on flash memory storage technology


 Flash memory is non-volatile, Electrically Erasable
Programmable Read Only Memory (EEPROM) chip
 It is a highly durable solid-state storage having data
retention capability of more than 10 years

Ref. Page 146 Chapter 08: Secondary Storage Devices Slide 92/117
Computer Fundamentals: Pradeep K. Sinha & Priti Sinha

A Flash Drive (Pen Drive)

Read/write Part that plugs into a


light indicator computer’s USB port
Main body Cover

Strap hole (can be used


to hang it With a string

Write protect tab

Ref. Page 147 Chapter 08: Secondary Storage Devices Slide 93/117
Computer Fundamentals: Pradeep K. Sinha & Priti Sinha

Memory Storage Devices

Memory Card (SD/MMC)


 Flash memory based cards are available as removable
storage device in different types of electronic equipment
 The most popular ones are Secure Digital (SD) and
Multimedia Card (MMC)
 These cards are used in various types of digital devices
 Each of these cards has its own interface and specific design
features

Ref. Page 147 Chapter 08: Secondary Storage Devices Slide 94/117
Computer Fundamentals: Pradeep K. Sinha & Priti Sinha

Flash Memory Based Card


Direction notch
Write-protect lock (guides which side of the
(slides down/up to lock/ card should be inserted first
unlock write operation) in the electronic equipment)

Vendor name

Storage
capacity

Ref. Page 147 Chapter 08: Secondary Storage Devices Slide 95/117
Computer Fundamentals: Pradeep K. Sinha & Priti Sinha

Hybrid Secondary Storage Drives

 Both SSD and HDD coexist in such systems

 The two commonly used configurations are:

 Dual-drive system

 SSD as cache and HDD as normal secondary storage

Ref. Page 148 Chapter 08: Secondary Storage Devices Slide 96/117
Computer Fundamentals: Pradeep K. Sinha & Priti Sinha

Mass Storage Devices

Chapter 08: Secondary Storage Devices Slide 97/117


Computer Fundamentals: Pradeep K. Sinha & Priti Sinha

Mass Storage Devices


 As the name implies, these are storage systems
having several trillions of bytes of data storage
capacity
 They use multiple units of a storage media as a single
secondary storage device
 The three commonly used types are:
1. Disk array, which uses a set of magnetic disks
2. Automated tape library, which uses a set of
magnetic tapes
3. CD-ROM Jukebox, which uses a set of CD-ROMs
 They are relatively slow having average access times
in seconds

Ref. Page 148 Chapter 08: Secondary Storage Devices Slide 98/117
Computer Fundamentals: Pradeep K. Sinha & Priti Sinha

Disk Array

 Set of hard disks and hard disk drives with a


controller mounted in a single box, forming a single
large storage unit
 It is commonly known as a RAID (Redundant Array
of Inexpensive Disks)
 As a secondary storage device, provides enhanced
storage capacity, enhanced performance, and
enhanced reliability

Ref. Page 148 Chapter 08: Secondary Storage Devices Slide 99/117
Computer Fundamentals: Pradeep K. Sinha & Priti Sinha

Disk Array
 Enhanced storage capacity is achieved by using
multiple disks
 Enhanced performance is achieved by using parallel
data transfer technique from multiple disks
 Enhanced reliability is achieved by using techniques
such as mirroring or striping
 In mirroring, the system makes exact copies of files
on two hard disks
 In striping, a file is partitioned into smaller parts and
different parts of the file are stored on different disks

Ref. Page 148 Chapter 08: Secondary Storage Devices Slide 100/117
Computer Fundamentals: Pradeep K. Sinha & Priti Sinha

A RAID Unit

Multiple
disks

RAID Controller

Computer

Ref. Page 148 Chapter 08: Secondary Storage Devices Slide 101/117
Computer Fundamentals: Pradeep K. Sinha & Priti Sinha

Automated Tape Library

 Set of magnetic tapes and magnetic tape drives with


a controller mounted in a single box, forming a
single large storage unit
 Large tape library can accommodate up to several
hundred high capacity magnetic tapes bringing the
storage capacity of the storage unit to several
terabytes
 Typically used for data archiving and as on-line data
backup devices for automated backup in large
computer centers

Ref. Page 149 Chapter 08: Secondary Storage Devices Slide 102/117
Computer Fundamentals: Pradeep K. Sinha & Priti Sinha

CD-ROM Jukebox
 Set of CD-ROMs and CD-ROM drives with a controller
mounted in a single box, forming a single large
storage unit
 Large CD-ROM jukebox can accommodate up to
several hundred CD-ROM disks bringing the storage
capacity of the storage unit to several terabytes
 Used for archiving read-only data in such
applications as on-line museums, on-line digital
libraries, on-line encyclopedia, etc

Ref. Page 149 Chapter 08: Secondary Storage Devices Slide 103/117
Computer Fundamentals: Pradeep K. Sinha & Priti Sinha

Data Backup

Chapter 08: Secondary Storage Devices Slide 104/117


Computer Fundamentals: Pradeep K. Sinha & Priti Sinha

What is Data Backup?

 Data backup is the process of creating a copy of some


data from an on-line storage device to a secondary
storage backup device
 Copy is used for off-line storage
 It can be retrieved from the backup device and stored
back on the on-line storage device

Ref. Page 150 Chapter 08: Secondary Storage Devices Slide 105/117
Computer Fundamentals: Pradeep K. Sinha & Priti Sinha

Why Backup Data?

 On-line storage device can be damaged or lost in any of


the following ways
 A disk crash
 A virus attack
 A hardware malfunction
 An unintended accidental deletion of useful files
 A natural disaster like fire or earthquake damaging the
computer system
 Amount of time it would take us to re-create all files is far
greater than the few minutes it takes to back them up

Ref. Page 150 Chapter 08: Secondary Storage Devices Slide 106/117
Computer Fundamentals: Pradeep K. Sinha & Priti Sinha

Types of Backup
 Full backup
 All data on an on-line secondary storage device is copied
on a backup device at the time of backup
 Full backup is simpler and a little safer
 To restore a particular file we need to search for it at
only one place
 Incremental backup
 Only newly created files or files that have been changed
since the last backup are copied on backup device from
on-line secondary storage device at the time of backup
 Incremental backup is faster than full backup
 To restore a particular file we need to search for it on
several backups

Ref. Page 150 Chapter 08: Secondary Storage Devices Slide 107/117
Computer Fundamentals: Pradeep K. Sinha & Priti Sinha

Backup Policy

 What is the periodicity of backup?


 Normally, periodicity depends on the nature of usage
and criticality of stored data
 Whether to take full or incremental backup?
 If a user creates only a few files, daily/weekly
incremental backup is sufficient
 If a user frequently creates many files, weekly full
backups are safer
 What storage media to use for backup?
 Small backups are taken normally on CD/pen drives
 Whereas larger backups are taken on magnetic tapes
(Continued on next slide…)

Ref. Page 151 Chapter 08: Secondary Storage Devices Slide 108/117
Computer Fundamentals: Pradeep K. Sinha & Priti Sinha

Backup Policy

 Who takes backup?


 In case of PCs, it is the PC user
 In case of large computer centers, normally the
administrators of the system
 Where to store the backup media with the backed up data?
 It is suggested to store the backup media in a building
that is away from the building where backup was taken
to protect the data against natural calamities

Ref. Page 151 Chapter 08: Secondary Storage Devices Slide 109/117
Computer Fundamentals: Pradeep K. Sinha & Priti Sinha

On-line, Near-line, and


Off-line Storage

Chapter 08: Secondary Storage Devices Slide 110/117


Computer Fundamentals: Pradeep K. Sinha & Priti Sinha

On-line, Near-line, and Off-line Storage

 On-line storage
 On-line storage device is under direct control of the
processing unit of the computer
 Near-line storage
 Near-line storage device is an intermediate storage
between on-line storage and off-line storage
 Off-line storage
 Off-line storage is not under direct control of any
computer

Ref. Page 151 Chapter 08: Secondary Storage Devices Slide 111/117
Computer Fundamentals: Pradeep K. Sinha & Priti Sinha

Hierarchical Storage
System (HSS)

Chapter 08: Secondary Storage Devices Slide 112/117


Computer Fundamentals: Pradeep K. Sinha & Priti Sinha

Hierarchical Storage System (HSS)

Ref. Page 153 Chapter 08: Secondary Storage Devices Slide 113/117
Computer Fundamentals: Pradeep K. Sinha & Priti Sinha

Hierarchical Storage Management (HSM)

 HSM software is an integral part of an HSS

 It automatically moves the more frequently used data (files)


to higher layers of the HSS (having faster access time) from
its lower layers (having slower access time)

 For this, it continuously monitors the data access pattern by


the users of HSS

Ref. Page 152 Chapter 08: Secondary Storage Devices Slide 114/117
Computer Fundamentals: Pradeep K. Sinha & Priti Sinha

Hierarchical Storage Management (HSM)


 Important issue in HSS is how to decide which data should
reside on which storage tier
 This is handled automatically by a software called Hierarchical
Storage Management (HSM)
 All HSSs have HSM software, which monitors the way data is
used, and makes decisions as to which data can be moved
safely to slower devices
 Frequently used data are stored on on-line storage
 Moved eventually by HSM to near-line storage if they are not
accessed for a certain period
 Users do not need to know or keep track of where the
accessed data is stored and how to get it back
 Computer retrieves the data automatically

Ref. Page 152 Chapter 08: Secondary Storage Devices Slide 115/117
Computer Fundamentals: Pradeep K. Sinha & Priti Sinha

Key Words/Phrases
 Automated tape library  Floppy disk
 Auxiliary memory  Hard disk
 Block  Hard Disk Drive (HDD)
 Blocking  Hierarchical Storage System (HSS)
 Blocking factory  Inter-block gap (IBG)
 CD-ROM  Inter-record gap (IRG)
 CD-ROM jukebox  Land
 Check bit  Latency
 Cylinder  Magnetic disk
 Data transfer rate  Magnetic tape
 Direct access device  Magnetic tape drive
 Disk array  Mass storage devices
 Disk controller  Master file
 Disk drive  Odd parity
 Disk formatting  Off-line storage
 Disk pack  On-line storage
 DVD  Optical disk
 Even parity  Parallel representation
 File Allocation Tube (FAT)  Parity bit
 Pit

(Continued on next slide)

Chapter 08: Secondary Storage Devices Slide 116/117


Computer Fundamentals: Pradeep K. Sinha & Priti Sinha

Key Words/Phrases
 QIC Standard
 Record
 Redundant Array of Inexpensive Disks (RAID)
 Secondary storage
 Sector
 Seek time
 Sequential access device
 Solid State Drive (SSD)
 Storage hierarchy
 Tape controller
 Track
 Transaction file
 Winchester disk
 WORM disk
 Zip disk

Chapter 08: Secondary Storage Devices Slide 117/117


Computer Fundamentals : Pradeep K. Sinha & Priti Sinha

Computer Fundamentals

Pradeep K. Sinha
Priti Sinha

Chapter 9

Input-Output
Devices
Chapter 09: Input-Output Devices Slide 1/73
Computer Fundamentals : Pradeep K. Sinha & Priti Sinha

Learning Objectives
In this chapter you will learn about:

 Input/Output (I/O) devices


 Commonly used input devices
 Commonly used output devices
 Other concepts related to I/O devices

Chapter 09: Input-Output Devices Slide 2/73


Computer Fundamentals : Pradeep K. Sinha & Priti Sinha

I/O Devices
 Provide means of communication between a computer
and outer world
 Also known as peripheral devices because they
surround the CPU and memory of a computer system
 Input devices are used to enter data from the outside
world into primary storage
 Output devices supply results of processing from
primary storage to users

Ref. Page 158 Chapter 09: Input-Output Devices Slide 3/73


Computer Fundamentals : Pradeep K. Sinha & Priti Sinha

Role of I/O Devices

Input Results of
data CPU processing
Input Output
from and in human
Devices Devices
external Memory acceptable
world form

Input data coded Processed data


in internal form in internal form

Ref. Page 158 Chapter 09: Input-Output Devices Slide 4/73


Computer Fundamentals: Pradeep K. Sinha & Priti Sinha

Input Devices

Chapter 10: Computer Software Slide 5/36


Computer Fundamentals : Pradeep K. Sinha & Priti Sinha

Commonly Used Input Devices

 Keyboard devices
 Point-and-draw devices
 Data scanning devices
 Digitizer
 Electronic cards based devices
 Speech recognition devices
 Vision based devices

Ref. Page 159 Chapter 09: Input-Output Devices Slide 6/73


Computer Fundamentals : Pradeep K. Sinha & Priti Sinha

Keyboard Devices

 Allow data entry into a computer system by pressing a


set of keys (labeled buttons) neatly mounted on a
keyboard connected to a computer system
 101-keys QWERTY keyboard is most popular

Ref. Page 159 Chapter 09: Input-Output Devices Slide 7/73


Computer Fundamentals : Pradeep K. Sinha & Priti Sinha
The Layout of Keys on a
QWERTY Keyboard

Ref. Page 159 Chapter 09: Input-Output Devices Slide 8/73


Computer Fundamentals : Pradeep K. Sinha & Priti Sinha

Point-and-Draw Devices

 Used to rapidly point to and select a graphic icon or


menu item from multiple options displayed on the
Graphical User Interface (GUI) of a screen
 Used to create graphic elements on the screen such as
lines, curves, and freehand shapes
 Some commonly used point-and-draw devices are
mouse, track ball, joy stick, light pen, and touch screen

Ref. Page 159 Chapter 09: Input-Output Devices Slide 9/73


Computer Fundamentals : Pradeep K. Sinha & Priti Sinha

Mouse
 Mouse is the most popular point-and-draw device
 Mouse is a small hand-held device that fits comfortably in a
user’s palm
 It rolls on a small bearing and has one or more buttons on
the top
 When a user rolls a mouse on a flat surface, a graphics
cursor moves on the terminal screen in the direction of the
mouse’s movement
 Different applications display the graphics cursor as different
symbols
 Graphics cursor, irrespective of its size and shape, has a
pixel-size point that is the point of reference to decide the
position of the cursor on the screen. This point is called hot
spot

Ref. Page 160 Chapter 09: Input-Output Devices Slide 10/73


Computer Fundamentals : Pradeep K. Sinha & Priti Sinha

Mouse

Click Button

Ref. Page 160 Chapter 09: Input-Output Devices Slide 11/73


Computer Fundamentals : Pradeep K. Sinha & Priti Sinha

Types of Mouse

 Mechanical mouse
 Mechanical mouse has a ball inside it that partially projects out
through an opening in its base
 Ball rolls due to surface friction when the mouse is moved on a
flat surface
 On two sides of the ball are two small wheels that spin to
match the speed of the ball. Each wheel of the mouse is
connected to a sensor
 As the mouse ball rolls when a user moves the mouse, the
sensors detect how much each wheel spins and send this
information to the computer in the form of changes to the
current position

(Continued on next slide…)

Ref. Page 161 Chapter 09: Input-Output Devices Slide 12/73


Computer Fundamentals : Pradeep K. Sinha & Priti Sinha

Types of Mouse
 Optical mouse
 An optical mouse has no mechanical parts like the ball and
wheels
 It has a built-in photo-detector
 When a user moves the mouse on a special pad with gridlines,
the photo-detector senses each horizontal and vertical line on
the pad, and sends this information to the computer in the
form of changes to the current position
 One, Two, and Three buttons mouse
 Mouse can have one, two, or three buttons
 With a mouse having multiple buttons, the leftmost button is
the main button that allows for most mouse operations
 A user can configure another button as main button
(Continued on next slide…)

Ref. Page 161 Chapter 09: Input-Output Devices Slide 13/73


Computer Fundamentals : Pradeep K. Sinha & Priti Sinha

Types of Mouse

 Serial and bus mouse


 A serial mouse plugs into a serial port
 A bus mouse requires a special electronic card, which provides
a special port just for connecting the mouse to a computer
 Wired and cordless mouse
 Wired mouse is connected to a computer with a small cord
 A cordless mouse operates by transmitting a low-intensity
radio or infrared signal

Ref. Page 161 Chapter 09: Input-Output Devices Slide 14/73


Computer Fundamentals : Pradeep K. Sinha & Priti Sinha

Trackball

 A trackball is a pointing device similar to a mechanical


mouse
 Roller ball is placed on the top along with the buttons
 We have to roll the ball with hand
 Trackball requires less space than a mouse for operation
 Trackball is a preferred device for CAD/CAM applications

Ref. Page 161 Chapter 09: Input-Output Devices Slide 15/73


Computer Fundamentals : Pradeep K. Sinha & Priti Sinha

Trackball

Ball is rolled
with fingers

Click button

Ref. Page 162 Chapter 09: Input-Output Devices Slide 16/73


Computer Fundamentals : Pradeep K. Sinha & Priti Sinha

Joystick
 Joystick is a pointing device that works on the same
principle as a trackball
 To make the movements of the spherical ball easier, it is
placed in a socket with a stick mounted on it
 User holds the stick in his/her hand and moves it around to
move the spherical ball
 User can move the stick forward or backward, left or right,
to move and position the graphics cursor at a desired
position
 Joysticks use potentiometers to sense stick and ball
movements
 A button on top of the stick enables a user to select the
option pointed to by the cursor

Ref. Page 162 Chapter 09: Input-Output Devices Slide 17/73


Computer Fundamentals : Pradeep K. Sinha & Priti Sinha

Joystick

Click button

Stick

Socket

Light
indicator

Ref. Page 162 Chapter 09: Input-Output Devices Slide 18/73


Computer Fundamentals : Pradeep K. Sinha & Priti Sinha

Electronic Pen
 Light pen
 Uses a photoelectric cell and an optical lens mounted in a pen-shaped
case
 It focuses on to it any light in its field of view
 It detects the light emitted from a limited field of view of the monitor’s
display
 System transmits this electric response to a processor, which identifies
the menu item or icon that is triggering the photocell
 Pen has a finger-operated button

 Writing pen with pad


 This type of electronic pen comes with a special type of writing pad
 User writes on the pad with the electronic pen whatever data he/she
wants to input to the computer
 This input device with handwriting recognition software is used often as
an easy way to input text and freehand drawings into computer

Ref. Page 162 Chapter 09: Input-Output Devices Slide 19/73


Computer Fundamentals : Pradeep K. Sinha & Priti Sinha

Touch Screen

 Most simple, intuitive, and easiest to learn of all input


devices
 Enables users to choose from available options by
simply touching with their finger the desired icon or
menu item displayed on the screen
 Most preferred human-computer interface used in
information kiosks (unattended interactive information
systems such as automatic teller machine or ATM)

Ref. Page 163 Chapter 09: Input-Output Devices Slide 20/73


Computer Fundamentals : Pradeep K. Sinha & Priti Sinha

Data Scanning Devices

 Input devices that enable direct data entry into a


computer system from source documents
 Eliminate the need to key in text data into the computer
 Due to reduced human effort in data entry, they
improve data accuracy and also increase the timeliness
of the information processed
 Demand high quality of input documents
 Some data scanning devices are also capable of
recognizing marks or characters
 Form design and ink specification usually becomes more
critical for accuracy

Ref. Page 164 Chapter 09: Input-Output Devices Slide 21/73


Computer Fundamentals : Pradeep K. Sinha & Priti Sinha

Image Scanner

 Input device that translates paper documents into an


electronic format for storage in a computer
 Electronic format of a scanned image is its bit map
representation
 Stored image can be altered or manipulated with an
image-processing software

Ref. Page 164 Chapter 09: Input-Output Devices Slide 22/73


Computer Fundamentals : Pradeep K. Sinha & Priti Sinha

Two Common Types of Image Scanners

A flat-bed scanner A hand-held scanner

Ref. Page 164 Chapter 09: Input-Output Devices Slide 23/73


Computer Fundamentals : Pradeep K. Sinha & Priti Sinha
Optical Character Recognition (OCR)
Device

 Scanner equipped with a character recognition software


(called OCR software) that converts the bit map images
of characters to equivalent ASCII codes
 Enables word processing of input text and also requires
less storage for storing the document as text rather than
an image
 OCR software is extremely complex because it is difficult
to make a computer recognize an unlimited number of
typefaces and fonts
 Two standard OCR fonts are OCR-A (American standard)
and OCR-B (European standard)

Ref. Page 164 Chapter 09: Input-Output Devices Slide 24/73


Computer Fundamentals : Pradeep K. Sinha & Priti Sinha

Optical Mark Reader (OMR)

 Scanner capable of recognizing a pre-specified type of


mark by pencil or pen
 Very useful for grading tests with objective type
questions, or for any input data that is of a choice or
selection nature
 Technique used for recognition of marks involves focusing
a light on the page being scanned and detecting the
reflected light pattern from the marks

Ref. Page 166 Chapter 09: Input-Output Devices Slide 25/73


Computer Fundamentals : Pradeep K. Sinha & Priti Sinha

Sample Use of OMR


For each question, four options are given out of which only one is
correct. Choose the correct option and mark your choice against
the corresponding question number in the given answer sheet by
darkening the corresponding circle with a lead pencil.

1. The binary equivalent of decimal 4 is:


a) 101
b) 111
c) 001
d) 100
Indicates direction in which the
2. The full form of CPU is: sheet should be fed to the OMR
a) Cursor Positioning Unit 1.
b) Central Power Unit a b c d
c) Central Processing Unit
d) None of the above 2.
a b c d
3. Which is the largest unit of storage among the following: 3.
a) Terabyte a b c d
b) Kilobyte
c) Megabyte (b) Pre-printed answer sheet
d) Gigabyte

(a) Question sheet


A sample use of OMR for grading tests with objective type questions

Ref. Page 166 Chapter 09: Input-Output Devices Slide 26/73


Computer Fundamentals : Pradeep K. Sinha & Priti Sinha

Bar-code Reader

 Scanner used for reading (decoding) bar-coded data


 Bar codes represent alphanumeric data by a
combination of adjacent vertical lines (bars) by
varying their width and the spacing between them
 Scanner uses laser-beam to stroke across pattern of
bar code. Different patterns of bars reflect the beam
in different ways sensed by a light-sensitive detector
 Universal Product Code (UPC) is the most widely
known bar coding system

Ref. Page 166 Chapter 09: Input-Output Devices Slide 27/73


Computer Fundamentals : Pradeep K. Sinha & Priti Sinha

An Example of UPC Bar Code

Product category character


0 – grocery products
3 – drugs and health related 0
products, etc.

21000 67520

Manufacturer/supplier
identification number Specific product code
number

Ref. Page 167 Chapter 09: Input-Output Devices Slide 28/73


Computer Fundamentals : Pradeep K. Sinha & Priti Sinha

Magnetic-Ink Character Recognition (MICR)

 MICR is used by banking industry for faster processing


of large volume of cheques
 Bank’s identification code (name, branch, etc.), account
number and cheque number are pre-printed (encoded)
using characters from a special character set on all
cheques
 Special ink is used that contains magnetizable particles
of iron oxide
 MICR reader-sorter reads data on cheques and sorts
them for distribution to other banks or for further
processing

Ref. Page 167 Chapter 09: Input-Output Devices Slide 29/73


Computer Fundamentals : Pradeep K. Sinha & Priti Sinha

MICR Character Set (E13B Font)

 It consists of numerals 0 to 9 and four special characters


 MICR is not adopted by other industries because it supports only
14 symbols

Ref. Page 168 Chapter 09: Input-Output Devices Slide 30/73


Computer Fundamentals : Pradeep K. Sinha & Priti Sinha

Digitizer

 Input device used for converting (digitizing) pictures,


maps and drawings into digital form for storage in
computers
 Commonly used in the area of Computer Aided
Design (CAD) by architects and engineers to design
cars, buildings medical devices, robots, mechanical
parts, etc.
 Used in the area of Geographical Information System
(GIS) for digitizing maps available in paper form

Ref. Page 168 Chapter 09: Input-Output Devices Slide 31/73


Computer Fundamentals : Pradeep K. Sinha & Priti Sinha

Digitizer

Table top
Digitizing tablet

Cursor
Stylus

Ref. Page 168 Chapter 09: Input-Output Devices Slide 32/73


Computer Fundamentals : Pradeep K. Sinha & Priti Sinha

Electronic-card Reader
 Electronic cards are small plastic cards having encoded
data appropriate for the application for which they are
used
 Electronic-card reader (normally connected to a
computer) is used to read data encoded on an
electronic card and transfer it to the computer for
further processing
 Used together as a means of direct data entry into a
computer system
 Used by banks for use in automatic teller machines
(ATMs) and by organizations for controlling access of
employees to physically secured areas

Ref. Page 169 Chapter 09: Input-Output Devices Slide 33/73


Computer Fundamentals : Pradeep K. Sinha & Priti Sinha

Speech Recognition Devices

 Input device that allows a person to input data to a


computer system by speaking to it
 Today’s speech recognition systems are limited to
accepting few words within a relatively small domain
and can be used to enter only limited kinds and
quantities of data

Ref. Page 169 Chapter 09: Input-Output Devices Slide 34/73


Computer Fundamentals : Pradeep K. Sinha & Priti Sinha

Types of Speech Recognition Systems

 Single word recognition systems can recognize only a


single spoken words, such as YES, NO, MOVE, STOP, at
a time. Speaker-independent systems are mostly of
this type
 Continuous speech recognition systems can recognize
spoken sentences, such as MOVE TO THE NEXT BLOCK.
Such systems are normally speaker-dependent

Ref. Page 169 Chapter 09: Input-Output Devices Slide 35/73


Computer Fundamentals : Pradeep K. Sinha & Priti Sinha

Uses of Speech Recognition Systems

 For inputting data to a computer system by a person in


situations where his/her hands are busy, or his/her eyes
must be fixed on a measuring instrument or some other
object
 For data input by dictation of long text or passage for
later editing and review
 For authentication of a user by a computer system
based on voice input
 For limited use of computers by individuals with
physical disabilities

Ref. Page 169 Chapter 09: Input-Output Devices Slide 36/73


Computer Fundamentals : Pradeep K. Sinha & Priti Sinha

Vision-Input Systems

 Allow computer to accept input just by seeing an object.


 Input data is normally an object’s shape and features in
the form of an image
 Mainly used today in factories for designing industrial
robots that are used for quality-control and assembly
processes

Ref. Page 170 Chapter 09: Input-Output Devices Slide 37/73


Computer Fundamentals: Pradeep K. Sinha & Priti Sinha

Output Devices

Chapter 10: Computer Software Slide 38/36


Computer Fundamentals : Pradeep K. Sinha & Priti Sinha

Commonly Used Output Devices

 Monitors
 Printers
 Plotters
 Screen image projector
 Voice response systems

Ref. Page 170 Chapter 09: Input-Output Devices Slide 39/73


Computer Fundamentals : Pradeep K. Sinha & Priti Sinha

Types of Output
 Soft-copy output
 Not produced on a paper or some material that can be touched
and carried for being shown to others
 Temporary in nature and vanish after use
 Examples are output displayed on a terminal screen or spoken out
by a voice response system
 Hard-copy output
 Produced on a paper or some material that can be touched and
carried for being shown to others
 Permanent in nature and can be kept in paper files or can be
looked at a later time when the person is not using the computer
 Examples are output produced by printers or plotters on paper

Ref. Page 170 Chapter 09: Input-Output Devices Slide 40/73


Computer Fundamentals : Pradeep K. Sinha & Priti Sinha

Monitors

 Monitors are the most popular output devices used for


producing soft-copy output
 Display the output on a television like screen
 Monitor associated with a keyboard is called a video
display terminal (VDT). It is the most popular I/O
device

Ref. Page 171 Chapter 09: Input-Output Devices Slide 41/73


Computer Fundamentals : Pradeep K. Sinha & Priti Sinha

Monitors

Monitor

Keyboard

A video display terminal consists of a monitor and a keyboard

Ref. Page 171 Chapter 09: Input-Output Devices Slide 42/73


Computer Fundamentals : Pradeep K. Sinha & Priti Sinha

Types of Monitors

 Cathode-ray-tube (CRT) monitors look like a television


and are normally used with non-portable computer
systems
 LCD (Liquid Crystal Display) flat-panel monitors are
thinner and lighter and are commonly used with portable
computer systems like notebook computers. Now they
are also used with non-portable desktop computer
systems because they occupy less table space.

Ref. Page 171 Chapter 09: Input-Output Devices Slide 43/73


Computer Fundamentals : Pradeep K. Sinha & Priti Sinha

CRT and LCD Monitors

CRT Monitor LCD Monitor

Ref. Page 171 Chapter 09: Input-Output Devices Slide 44/73


Computer Fundamentals : Pradeep K. Sinha & Priti Sinha

Printers

Most common output devices for producing hard-copy


output

Ref. Page 171 Chapter 09: Input-Output Devices Slide 45/73


Computer Fundamentals : Pradeep K. Sinha & Priti Sinha

Dot-Matrix Printers

 Character printers that form characters and all kinds of


images as a pattern of dots
 Print many special characters, different sizes of print
and graphics such as charts and graphs
 Impact printers can be used for generating multiple
copies by using carbon paper or its equivalent
 Slow, with speeds usually ranging between 30 to 600
characters per second
 Cheap in both initial cost and cost of operation

Ref. Page 171 Chapter 09: Input-Output Devices Slide 46/73


Computer Fundamentals : Pradeep K. Sinha & Priti Sinha

Formation of Characters as a pattern of dots

ABCDEFGHIJKLM
NOPQRSTUVWXYZ
0123456789-.,
&/$*#%@=(+)

Ref. Page 171 Chapter 09: Input-Output Devices Slide 47/73


Computer Fundamentals : Pradeep K. Sinha & Priti Sinha

Dot Matrix Printer Printing Mechanism

Inked Paper below Print head Direction of movement


ribbon the ribbon pins of print head pins

Direction of movement
of print head
Printed characters
formed of dots in a 5 Print head
x 7 matrix

Ref. Page 172 Chapter 09: Input-Output Devices Slide 48/73


Computer Fundamentals : Pradeep K. Sinha & Priti Sinha

Dot Matrix Printer

Ref. Page 172 Chapter 09: Input-Output Devices Slide 49/73


Computer Fundamentals : Pradeep K. Sinha & Priti Sinha

Inkjet Printers

 Character printers that form characters and all kinds of


images by spraying small drops of ink on to the paper
 Print head contains up to 64 tiny nozzles that can be
selectively heated up in a few micro seconds by an
integrated circuit register
 To print a character, the printer selectively heats the
appropriate set of nozzles as the print head moves
horizontally
 Can print many special characters, different sizes of
print, and graphics such as charts and graphs

(Continued on next slide)

Ref. Page 172 Chapter 09: Input-Output Devices Slide 50/73


Computer Fundamentals : Pradeep K. Sinha & Priti Sinha

Inkjet Printers

 Non-impact printers. Hence, they cannot produce


multiple copies of a document in a single printing
 Can be both monochrome and color
 Slower than dot-matrix printers with speeds usually
ranging between 40 to 300 characters per second
 More expensive than a dot-matrix printer

Ref. Page 172 Chapter 09: Input-Output Devices Slide 51/73


Computer Fundamentals : Pradeep K. Sinha & Priti Sinha

An Inkjet Printer

Ref. Page 173 Chapter 09: Input-Output Devices Slide 52/73


Computer Fundamentals : Pradeep K. Sinha & Priti Sinha

Drum Printers
 Line printers that print one line at a time
 Have a solid cylindrical drum with characters embossed
on its surface in the form of circular bands
 Set of hammers mounted in front of the drum in such a
manner that an inked ribbon and paper can be placed
between the hammers and the drum
 Can only print a pre-defined set of characters in a pre-
defined style that is embossed on the drum
 Impact printers and usually monochrome
 Typical speeds are in the range of 300 to 2000 lines per
minute

Ref. Page 173 Chapter 09: Input-Output Devices Slide 53/73


Computer Fundamentals : Pradeep K. Sinha & Priti Sinha

Printing Mechanism of a Drum Printer

Hammers (one for


each band)
Paper
Ribbon
WW W WWWWWWWWWWW
V V V V V V V V V V VV V V
U U U U U U U U U U U U U U
T T T T T T T T T T T T T T
S S S S S S S S S S S S S S
R R R R R R R R R R R R R R
Solid cylindrical Q Q Q Q Q Q Q Q Q Q Q Q Q Q
drum with P P P P P P P P P P P P P P
embossed O O O O O O O O O O O O O O
N N N N N N N N N N NN N N
characters

Total number of bands is


equal to the maximum
number of characters (print
positions) on a line. Each
band has all characters
supported by the printer.

Ref. Page 174 Chapter 09: Input-Output Devices Slide 54/73


Computer Fundamentals : Pradeep K. Sinha & Priti Sinha

Chain/Band Printers

 Line printers that print one line at a time


 Consist of a metallic chain/band on which all
characters of the character set supported by the
printer are embossed
 Also have a set of hammers mounted in front of the
chain/band in such a manner that an inked ribbon
and paper can be placed between the hammers and
the chain/band

Ref. Page 174 Chapter 09: Input-Output Devices Slide 55/73


Computer Fundamentals : Pradeep K. Sinha & Priti Sinha

Chain/Band Printers

 Can only print pre-defined sets of characters that are


embossed on the chain/band used with the printer
 Cannot print any shape of characters, different sizes of
print, and graphics such as charts and graphs
 Are impact printers and can be used for generating
multiple copies by using carbon paper or its equivalent
 Are usually monochrome
 Typical speeds are in the range of 400 to 3000 lines
per minute

Ref. Page 174 Chapter 09: Input-Output Devices Slide 56/73


Computer Fundamentals : Pradeep K. Sinha & Priti Sinha

Printing Mechanism of a Chain/Band Printer

One section of 48 Direction of


Complete chain is characters movement
composed of five of the chain
sections of 48
characters each
Paper

Ribbon

Hammers

132 print positions

Ref. Page 175 Chapter 09: Input-Output Devices Slide 57/73


Computer Fundamentals : Pradeep K. Sinha & Priti Sinha

Laser Printers
 Page printers that print one page at a time
 Consist of a laser beam source, a multi-sided mirror, a
photoconductive drum and toner (tiny particles of
oppositely charged ink)
 To print a page, the laser beam is focused on the electro
statically charged drum by the spinning multi-sided
mirror
 Toner sticks to the drum in the places the laser beam
has charged the drum’s surface.
 Toner is then permanently fused on the paper with heat
and pressure to generate the printer output
 Laser printers produce very high quality output having
resolutions in the range of 600 to 1200 dpi
(Continued on next slide)

Ref. Page 175 Chapter 09: Input-Output Devices Slide 58/73


Computer Fundamentals : Pradeep K. Sinha & Priti Sinha

Laser Printers
 Can print many special characters, different sizes of
print, and graphics such as charts and graphs
 Are non-impact printers
 Most laser printers are monochrome, but color laser
printers are also available
 Low speed laser printers can print 4 to 12 pages per
minute. Very high-speed laser printers can print 500
to 1000 pages per minute
 More expensive than other printers

Ref. Page 175 Chapter 09: Input-Output Devices Slide 59/73


Computer Fundamentals : Pradeep K. Sinha & Priti Sinha

A Laser Printer

Ref. Page 175 Chapter 09: Input-Output Devices Slide 60/73


Computer Fundamentals : Pradeep K. Sinha & Priti Sinha

Plotters
 Plotters are an ideal output device for architects,
engineers, city planners, and others who need to
routinely generate high-precision, hard-copy graphic
output of widely varying sizes
 Two commonly used types of plotters are:
 Drum plotter, in which the paper on which the
design has to be made is placed over a drum that
can rotate in both clockwise and anti-clockwise
directions
 Flatbed plotter, in which the paper on which the
design has to be made is spread and fixed over a
rectangular flatbed table

Ref. Page 176 Chapter 09: Input-Output Devices Slide 61/73


Computer Fundamentals : Pradeep K. Sinha & Priti Sinha

Plotters

Paper

Design drawn
on the paper
Design drawn
on the paper

Paper

A drum plotter A flatbed plotter

Ref. Page 177 Chapter 09: Input-Output Devices Slide 62/73


Computer Fundamentals : Pradeep K. Sinha & Priti Sinha

3D Printers

 They print (create) 3D objects


 They use Additive Manufacturing technique
 They follow a 3-step process:

1. First create a 3D digital file (3D model) of the object


2. Then slice the 3D model into horizontal layers
3. Then upload the sliced file and print

Ref. Page 177 Chapter 09: Input-Output Devices Slide 63/73


Computer Fundamentals : Pradeep K. Sinha & Priti Sinha

Types of 3D Printers

 3D printers mainly differ in the way they build an object layer-


by-layer and the material they use for manufacturing objects
 Some commonly used 3D printing technologies are:

 Fused Deposition Modeling (FDM)


 STereoLithography (STL)
 Digital Light Processing (DLP)
 Selective Layer Sintering (SLS)

Ref. Page 178 Chapter 09: Input-Output Devices Slide 64/73


Computer Fundamentals : Pradeep K. Sinha & Priti Sinha

Applications of 3D Printers

 Rapid prototyping

 Rapid manufacturing of customized designs

 Manufacturing body/engine parts

 Manufacturing implants and prosthetics

 Manufacturing hearing aid and dental appliances

 Manufacturing museum souvenirs

Ref. Page 179 Chapter 09: Input-Output Devices Slide 65/73


Computer Fundamentals : Pradeep K. Sinha & Priti Sinha

Fused Deposition Modeling (FDM)

Ref. Page 180 Chapter 09: Input-Output Devices Slide 66/73


Computer Fundamentals : Pradeep K. Sinha & Priti Sinha

Screen Image Projector

 An output device that can be directly plugged to a


computer system for projecting information from a
computer on to a large screen
 Useful for making presentations to a group of people
with direct use of a computer
 Full-fledged multimedia presentation with audio, video,
image, and animation can be prepared and made
using this facility

Ref. Page 181 Chapter 09: Input-Output Devices Slide 67/73


Computer Fundamentals : Pradeep K. Sinha & Priti Sinha

Screen Image Projector

Operations buttons

On/Off light indicator


Projection lens

Ref. Page 181 Chapter 09: Input-Output Devices Slide 68/73


Computer Fundamentals : Pradeep K. Sinha & Priti Sinha

Voice Response Systems


 Voice response system enables a computer to talk to
a user
 Has an audio-response device that produces audio
output
 Such systems are of two types:
 Voice reproduction systems
 Speech synthesizers

(Continued on next slide)

Ref. Page 181 Chapter 09: Input-Output Devices Slide 69/73


Computer Fundamentals : Pradeep K. Sinha & Priti Sinha

Voice Reproduction Systems

 Produce audio output by selecting an appropriate


audio output from a set of pre-recorded audio
responses
 Applications include audio help for guiding how to
operate a system, automatic answering machines,
video games, etc.

Ref. Page 181 Chapter 09: Input-Output Devices Slide 70/73


Computer Fundamentals : Pradeep K. Sinha & Priti Sinha

Speech Synthesizers

 Converts text information into spoken sentences


 Used for applications such as:
 Reading out text information to blind persons
 Allowing those persons who cannot speak to
communicate effectively
 Translating an entered text into spoken words in
a selected language

Ref. Page 182 Chapter 09: Input-Output Devices Slide 71/73


Computer Fundamentals : Pradeep K. Sinha & Priti Sinha

Key Words/Phrases
 3D Printer  Information Kiosk
 Bard code reader  Inkjet printer
 Cathode Ray Tube (CRT)  Input/Output device
 Chain/Band printer  Joystick
 Data scanning device  Keyboard device
 Digital Light Processing (DLP)  Laser printer
 Digitizer  Magnetic-Ink Character Recognition
 Digitizing tablet (MICR)
 Dot-Matrix printer  Monitor
 Drum plotter  Mouse
 Drum printer  Optical Character Recognition (OCR)
 Electronic card reader  Optical Mark Reader (OMR)
 Electronic Pen  Peripheral device
 Flatbed plotter  Phonemes
 Flatbed Scanner  Plotter
 Fused Deposition Modeling (FDM)  Point-and-draw device
 Graphical User Interface  Printer
 Hand-held scanner  QWERTY keyboard
 Hard-copy output  Screen Image Projector
 Image Scanner (Continued on next slide)

Chapter 09: Input-Output Devices Slide 72/73


Computer Fundamentals : Pradeep K. Sinha & Priti Sinha

Key Words/Phrases

 Selective Layer Sintering (SLS)


 Soft-copy output
 Speech synthesizer
 STereoLithography (STL)
 Stylus
 Touch Screen
 Trackball
 Universal Product Code (UPC)
 Video Display Terminal (VDT)
 Vision-input system
 Voice recognition device
 Voice reproduction system
 Voice response system

Chapter 09: Input-Output Devices Slide 73/73


Computer Fundamentals: Pradeep K. Sinha & Priti Sinha

Computer Fundamentals

Pradeep K. Sinha
Priti Sinha

Chapter 10

Computer Software
Chapter 10: Computer Software Slide 1/37
Computer Fundamentals: Pradeep K. Sinha & Priti Sinha

Learning Objectives

In this chapter you will learn about:

 Term “Software” and its relationship with “Hardware”


 Various types of software and their examples
 Relationship among hardware, system software,
application software, and users of a computer system
 Different ways of acquiring software
 Various steps involved in software development
 Software Engineering and CASE tools
 Firmware and Middleware

Chapter 10: Computer Software Slide 2/37


Computer Fundamentals: Pradeep K. Sinha & Priti Sinha

Software, Firmware
and Middleware

Chapter 10: Computer Software Slide 3/37


Computer Fundamentals: Pradeep K. Sinha & Priti Sinha

Software

 Hardware refers to the physical devices of a


computer system.
 Software refers to a collection of programs,
procedures, and associated documents describing the
programs, and how they are to be used.
 Program is a sequence of instructions written in a
language that can be understood by a computer
 Software package is a group of programs that solve
a specific problem or perform a specific type of job
(for example, word-processing package)

Ref. Page 186 Chapter 10: Computer Software Slide 4/37


Computer Fundamentals: Pradeep K. Sinha & Priti Sinha
Relationship Between Hardware and
Software

 Both hardware and software are necessary for a


computer to do useful job. They are complementary
to each other
 Same hardware can be loaded with different software
to make a computer system perform different types
of jobs
 Except for upgrades, hardware is normally a one-
time expense, whereas software is a continuing
expense
 Upgrades refer to renewing or changing components
like increasing the main memory, or hard disk
capacities, or adding speakers, modems, etc.

Ref. Page 187 Chapter 10: Computer Software Slide 5/37


Computer Fundamentals: Pradeep K. Sinha & Priti Sinha

Types of Software

Most software can be divided into two major categories:


 System software are designed to control the
operation and extend the processing capability of a
computer system
 Application software are designed to solve a
specific problem or to do a specific task

Ref. Page 187 Chapter 10: Computer Software Slide 6/37


Computer Fundamentals: Pradeep K. Sinha & Priti Sinha

System Software

 Make the operation of a computer system more effective


and efficient

 Help hardware components work together and provide


support for the development and execution of application
software

 Programs included in a system software package are


called system programs and programmers who
prepare them are called system programmers

 Examples of system software are operating systems,


programming language translators, utility programs, and
communications software

Ref. Page 187 Chapter 10: Computer Software Slide 7/37


Computer Fundamentals: Pradeep K. Sinha & Priti Sinha

Application Software

 Solve a specific problem or do a specific task


 Programs included in an application software
package are called application programs and the
programmers who prepare them are called
application programmers
 Examples of application software are word
processing, inventory management, preparation of
tax returns, banking, etc.

Ref. Page 188 Chapter 10: Computer Software Slide 8/37


Computer Fundamentals: Pradeep K. Sinha & Priti Sinha

Logical System Architecture

USERS

APPLICATION SOFTWARE

SYSTEM SOFTWARE

HARDWARE

Physical devices/components of
the computer system
Software that constitute the operating and programming
environment of the computer system

Software that do a specific task or solve a specific problem

Users normally interact with the system via the user


interfaces provided by the application software

Ref. Page 189 Chapter 10: Computer Software Slide 9/37


Computer Fundamentals: Pradeep K. Sinha & Priti Sinha

Firmware

 Firmware refers to a sequence of instructions (software)


substituted for hardware
 This software is stored in a read-only memory (ROM) chip of
the computer
 Initially, vendors supplied only system software in the form of
firmware
 Many vendors now supply even application programs as
firmware
 Firmware is frequently a cost-effective alternative to wired
electronic circuits
 Firmware has today made it possible to produce smart
machines of all types

Ref. Page 190 Chapter 10: Computer Software Slide 10/37


Computer Fundamentals: Pradeep K. Sinha & Priti Sinha

Middleware

 Basic idea here is to have a separate software layer that acts


as “glue” between the client and server parts of an application
 Provides a programming abstraction as well as masks the
heterogeneity of underlying networks, hardware, and
operating systems
 This software layer is known as middleware because it sits in
the middle, between the operating system and applications
 Middleware is defined as a set of tools and data that helps
applications use networked resources and services

Ref. Page 190 Chapter 10: Computer Software Slide 11/37


Computer Fundamentals: Pradeep K. Sinha & Priti Sinha

Two-tier, Client-server Architecture

Client computer Server computer

Client part of Server part of


application software – application software –
Includes user Includes application-
interface, application specific services,
logic, messaging application logic,
services, and messaging services,
management and and management and
support services support services

Operating system and Operating system and


network interfaces network interfaces

Network connection

Ref. Page 191 Chapter 10: Computer Software Slide 12/37


Computer Fundamentals: Pradeep K. Sinha & Priti Sinha

Three-tier, Client-server Architecture


Client computer Server computer

Client part of Server part of


application software – application software –
Includes user interface Includes application -
and business and specific services
application logic

Middleware services – Middleware services –


Includes APIs and Includes APIs and
client part of server part of
messaging, messaging,
management, and management, and
support services support services

Operating system and Operating system and


network interfaces network interfaces

Network connection

Ref. Page 191 Chapter 10: Computer Software Slide 13/37


Computer Fundamentals: Pradeep K. Sinha & Priti Sinha

Acquiring Software

Chapter 10: Computer Software Slide 14/37


Computer Fundamentals: Pradeep K. Sinha & Priti Sinha

Ways of Acquiring Software

 Buying pre-written software


 Ordering customized software
 Developing customized software
 Downloading public-domain software

Each of these ways of acquiring software has its own


advantages and limitations

Ref. Page 191 Chapter 10: Computer Software Slide 15/37


Computer Fundamentals: Pradeep K. Sinha & Priti Sinha

Buying Pre-written Software

 Prepare a list of all available software packages that can


perform the desired task
 Select those software packages only that meet the system
specifications
 Choose the best one
 Find out the source from where you can purchase the finally
selected software at the cheapest price

Ref. Page 192 Chapter 10: Computer Software Slide 16/37


Computer Fundamentals: Pradeep K. Sinha & Priti Sinha
Advantages and Limitations of
Buying Pre-written Software

 Usually costs less


 Planned activity can be stared almost immediately
 Often, operating efficiency and the capability to meet
specific needs of user more effectively in not as good
for pre-written software packages as for in-house
developed software packages

Ref. Page 192 Chapter 10: Computer Software Slide 17/37


Computer Fundamentals: Pradeep K. Sinha & Priti Sinha

Ordering Customized Software


 If none of the available pre-written software packages meet
the specific requirements of a user it becomes necessary for
the user to create a customized software package
 If a team does not exist in-house, the user must get it
created by another organization by placing an order for it
 Following steps are followed for this:
 User prepares a list of all user requirements carefully
 User then floats a tender for inviting quotations for creation of
the requisite software
 After receiving the quotations, the user selects a few of them
for further interaction based on the cost quoted by them, their
reputation in the market, their submitted proposal, etc.
 User then personally interacts with the representative(s) of
each of the selected vendors

Ref. Page 192 Chapter 10: Computer Software Slide 18/37


Computer Fundamentals: Pradeep K. Sinha & Priti Sinha

Ordering Customized Software


 User makes a final choice of the vendor to offer the contract for
creation of the requisite software
 Selected vendor then creates the software package and delivers
it to the user
 Vendor need not develop everything from scratch
 User may choose to place the order for both hardware and
software to a single vendor
 Vendor develops the software on the chosen hardware, and
delivers the software along with the hardware to the user
 This is referred to as an end-to-end solution or a turnkey solution

Ref. Page 192 Chapter 10: Computer Software Slide 19/37


Computer Fundamentals: Pradeep K. Sinha & Priti Sinha
Advantages & Limitations of Ordering
Customized Software

 User need not maintain its own software development team,


which is an expensive affair
 User needs to always depend on the vendor for carrying out
the changes and the vendor may separately charge for
every request for change

Ref. Page 193 Chapter 10: Computer Software Slide 20/37


Computer Fundamentals: Pradeep K. Sinha & Priti Sinha

Developing Customized Software


 If no pre-written software package meets the specific
requirements, and if the organization has in-house software
development team, it may choose to develop a customized
software package in-house
 Following steps are followed for in-house development of a
software package:
 Organization first constitutes a project team to develop the
software
 Team studies the requirements and plans functional modules
 It then analyzes which of the functional modules need to be
developed, and which of the functional modules’ requirements
are met with existing pre-written software
 Team next plans their programs and does coding, testing,
debugging, and documentation
(Continued on next slide…)

Ref. Page 193 Chapter 10: Computer Software Slide 21/37


Computer Fundamentals: Pradeep K. Sinha & Priti Sinha

Developing Customized Software

 Team then tests all the modules in an integrated manner


 Team then deploys the software for use by users
 Users then use the software and the project team members
responsible for maintenance activities maintain it

Ref. Page 193 Chapter 10: Computer Software Slide 22/37


Computer Fundamentals: Pradeep K. Sinha & Priti Sinha
Advantages & Limitations of Developing
Customized Software

 Easier to carry out changes in the software, if it is


developed in-house
 Developing software in-house means a major
commitment of time, money, and resources
 In-house software development team needs to be
maintained and managed

Ref. Page 194 Chapter 10: Computer Software Slide 23/37


Computer Fundamentals: Pradeep K. Sinha & Priti Sinha

Downloading Public-domain
Software
 Public-domain software is software available free or for a
nominal charge from the bulletin boards or user-group
libraries on the Internet
 Public-domain software is also referred to as shareware/
freeware
 They are also known as community-supported software as
mostly the authors do not support the product directly and
users of the software support and help each other
 Open Source Software (OSS): Usually, OSS allows a user to
download, view, modify, and distribute modified source code
to others

Ref. Page 194 Chapter 10: Computer Software Slide 24/37


Computer Fundamentals: Pradeep K. Sinha & Priti Sinha
Advantage & Limitations of Downloading
Public-domain Software

 Available for free or as shareware, and are usually accompanied


with source code
 Usually community-supported as author does not support users
directly
 Can be downloaded and used immediately
 They may not be properly tested before release
 Open Source Software (OSS) are becoming popular due to:
 Allows any user to download, view, modify, and redistribute
 User can fix bugs or change software to suit needs
 Copyright is protected for both original and subsequent
authors
 Not all open source software are free and vise-verse

Ref. Page 194 Chapter 10: Computer Software Slide 25/37


Computer Fundamentals: Pradeep K. Sinha & Priti Sinha

Software Development
Life Cycle (SDLC)

Chapter 10: Computer Software Slide 26/37


Computer Fundamentals: Pradeep K. Sinha & Priti Sinha
Software Development Life Cycle
(SDLC)
Requirement
specification

System analysis
and design

Implementation

Testing and
debugging

Deployment

Maintenance

(Continued on next slide…)

Ref. Page 195 Chapter 10: Computer Software Slide 27/37


Computer Fundamentals: Pradeep K. Sinha & Priti Sinha

Software Development Life Cycle (SDLC)


 Requirement specification
 Team defines all possible requirements of the software in this
phase
 System analysis and design
 Team studies the requirements specified in the first phase with
respect to available hardware and software technologies and
prepares a system design document
 Implementation
 This phase is also known as construction or code generation
because in this phase, the team constructs the various
software components specified in system design document

Ref. Page 195 Chapter 10: Computer Software Slide 28/37


Computer Fundamentals: Pradeep K. Sinha & Priti Sinha

Software Development Life Cycle (SDLC)


 Testing and debugging
 Team integrates the independently developed and tested
modules into a complete system
 Team then tests the integrated system to check if all modules
coordinate properly with each other
 Deployment
 Team deploys the software at user(s) site on (or along with)
associated hardware for use by intended user
 Maintenance
 Team fixes problems in the system in this phase

Ref. Page 195 Chapter 10: Computer Software Slide 29/37


Computer Fundamentals: Pradeep K. Sinha & Priti Sinha

Software Engineering

Chapter 10: Computer Software Slide 30/37


Computer Fundamentals: Pradeep K. Sinha & Priti Sinha

What is Software Engineering?

 Software is a set of computer programs, procedures, and


associated documents
 Engineering is systematic application of scientific knowledge
in creation and building of cost-effective solutions
 Software engineering is systematic application of principles
of computer science and mathematics in creation and
building of cost-effective software solutions

Ref. Page 197 Chapter 10: Computer Software Slide 31/37


Computer Fundamentals: Pradeep K. Sinha & Priti Sinha

Need for Software Engineering

 With software products growing in scale and complexity,


number of software developers involved in a software
development project has been increasing proportionately
 Managing the development of large software products and
maintaining them is a difficult task
 Progressively larger software products in sensitive
applications are being used
 Required correctness and reliability of software products is
increasing
 Quality and productivity demands for software products led
to the introduction of systematic practices (later on known as
software engineering practices)

Ref. Page 197 Chapter 10: Computer Software Slide 32/37


Computer Fundamentals: Pradeep K. Sinha & Priti Sinha

Goals of Software Engineering

 Correctness should be of very high degree


 Correctness refers to the degree to which a software product
performs its intended functions properly, consistently, and
predictably
 Usability should be of very high degree
 Usability refers to the ease with which a software product and
its associated documentation are usable
 Should be cost-effective
 Cost-effectiveness means that the total development and
operational costs of a software product should be as low as
possible

Ref. Page 197 Chapter 10: Computer Software Slide 33/37


Computer Fundamentals: Pradeep K. Sinha & Priti Sinha

Principles of Software Engineering


 Precise requirements definition
 Designer of a software product must define its requirements
precisely
 Modular structure
 Designer of a software product must structure it in a modular
fashion
 Modular design helps in distribution of development task of
different modules to different programmers
 Abstraction
 Software product should use abstraction and information hiding
 Object-oriented programming takes care of this aspect of
software engineering
 Abstraction helps in easy reusability of existing modules

Ref. Page 197 Chapter 10: Computer Software Slide 34/37


Computer Fundamentals: Pradeep K. Sinha & Priti Sinha

Principles of Software Engineering

 Uniformity
 Software product should maintain uniformity in design, coding,
documentation, etc. Uniformity ensures consistency
 CASE (Computer Aided Software Engineering) tools
provide a wide range of features for creation of better and
more reliable software products
 Design specification tools
 Allow programmers to design visually screens, menus, database
tables, reports, dialog boxes, and other key components of a program

 Code generation tools


 Generate source code (programs) from the design specification of a
software product

(Continued on next slide…)

Ref. Page 197 Chapter 10: Computer Software Slide 35/37


Computer Fundamentals: Pradeep K. Sinha & Priti Sinha

Principles of Software Engineering

 Testing and debugging tools


 Help programmers in testing and debugging of their programs

 Source-code analysis tools


 Help in optimizing a program by pointing out unreachable lines of
code and functions that the program never uses (calls)

 Documentation tools
 Assist in automatic generation of technical documents for a software
product

Ref. Page 197 Chapter 10: Computer Software Slide 36/37


Computer Fundamentals: Pradeep K. Sinha & Priti Sinha

Key Words/Phrases

 Application programmers  Public-domain software


 Application programs  Shareware
 Application software  Software
 CASE tools  Software Development
 Computer program Life Cycle (SDLC)
 Customized software  Software Engineering
 Database  Software package
 Education software  Spreadsheet
 End-to-end solution  System programmers
 Entertainment software  System programs
 Firmware  System software
 Graphics software  Turnkey solution
 Hardware  User-supported
 Middleware software
 Open Source Software  Utilities
 Personal assistance software  Waterfall model
 Pre-written software  Word-processing

Chapter 10: Computer Software Slide 37/37


Computer Fundamentals: Pradeep K. Sinha & Priti Sinha

Computer Fundamentals

Pradeep K. Sinha
Priti Sinha

Chapter 11

Planning the
Computer Program
Chapter 11: Planning the Computer Program Slide 1/50
Computer Fundamentals: Pradeep K. Sinha & Priti Sinha

Learning Objectives

In this chapter you will learn about:

 Programs must be planned before they are written


 Planning the logic of a computer program
 Commonly used tools for program planning
 Algorithm
 Flowchart
 Pseudocode

Chapter 11: Planning the Computer Program Slide 2/50


Computer Fundamentals: Pradeep K. Sinha & Priti Sinha

Purpose of Program
Planning and Algorithm

Chapter 10: Computer Software Slide 3/36


Computer Fundamentals: Pradeep K. Sinha & Priti Sinha

Purpose of Program Planning


 To write a correct program, a programmer must write
each and every instruction in the correct sequence
 Logic (instruction sequence) of a program can be very
complex
 Hence, programs must be planned before they are
written to ensure program instructions are:
 Appropriate for the problem
 In the correct sequence

Ref. Page 202 Chapter 11: Planning the Computer Program Slide 4/50
Computer Fundamentals: Pradeep K. Sinha & Priti Sinha

What is an Algorithm?
 Algorithm refers to the logic of a program
 It is a step-by-step description of how to arrive at a solution
to a given problem
 Is defined as a sequence of instructions that when executed
in the specified sequence, the desired results are obtained
 Instructions must possess following characteristics:
 Each instruction should be precise and unambiguous
 Each instruction should be executed in a finite time
 No instruction should be repeated infinitely. This ensures that
the algorithm terminates ultimately
 After executing the instructions (when the algorithm
terminates), the desired results are obtained

Ref. Page 203 Chapter 11: Planning the Computer Program Slide 5/50
Computer Fundamentals: Pradeep K. Sinha & Priti Sinha

Sample Algorithm (Example 1)


There are 50 students in a class who appeared in their
final examination. Their mark sheets have been given to
you.

The division column of the mark sheet contains the


division (FIRST, SECOND, THIRD or FAIL) obtained by the
student.

Write an algorithm to calculate and print the total number


of students who passed in FIRST division.

(Continued on next slide…)

Ref. Page 203 Chapter 11: Planning the Computer Program Slide 6/50
Computer Fundamentals: Pradeep K. Sinha & Priti Sinha

Sample Algorithm (Example 1)


Step 1: Initialize Total_First_Division and
Total_Marksheets_Checked to zero.

Step 2: Take the mark sheet of the next student.

Step 3: Check the division column of the mark sheet to see if it is


FIRST, if no, go to Step 5.

Step 4: Add 1 to Total_First_Division.

Step 5: Add 1 to Total_Marksheets_Checked.

Step 6: Is Total_Marksheets_Checked = 50, if no, go to Step 2.

Step 7: Print Total_First_Division.

Step 8: Stop.

Ref. Page 203 Chapter 11: Planning the Computer Program Slide 7/50
Computer Fundamentals: Pradeep K. Sinha & Priti Sinha

Sample Algorithm (Example 2)


There are 100 employees in an organization. The organization
wants to distribute annual bonus to the employees based on their
performance. The performance of the employees is recorded in
their annual appraisal forms.
Every employee’s appraisal form contains his/her basic salary and
the grade for his/her performance during the year. The grade is of
three categories – ‘A’ for outstanding performance, ‘B’ for good
performance, and ‘C’ for average performance.
It has been decided that the bonus of an employee will be 100% of
the basic salary for outstanding performance, 70% of the basic
salary for good performance, 40% of the basic salary for average
performance, and zero for all other cases.
Write an algorithm to calculate and print the total bonus amount to
be distributed by the organization.

(Continued on next slide…)

Ref. Page 204 Chapter 11: Planning the Computer Program Slide 8/50
Computer Fundamentals: Pradeep K. Sinha & Priti Sinha

Sample Algorithm (Example 2)


Step 1: Initialize Total_Bonus and Total_Employees_Checked to zero.

Step 2: Initialize Bonus and Basic_Salary to zero.

Step 3: Take the appraisal form of the next employee.

Step 4: Read the employee’s Basic_Salary and Grade.

Step 5: If Grade = A, then Bonus = Basic_Salary. Go to Step 8.

Step 6: If Grade = B, then Bonus = Basic_Salary x 0.7. Go to Step 8.

Step 7: If Grade = C, then Bonus = Basic_Salary x 0.4.

Step 8: Add Bonus to Total_Bonus.

Step 9: Add 1 to Total_Employees_Checked.

Step 10: If Total_Employees_Checked < 100, then go to Step 2.

Step 11: Print Total_Bonus.

Step 12: Stop.

Ref. Page 204 Chapter 11: Planning the Computer Program Slide 9/50
Computer Fundamentals: Pradeep K. Sinha & Priti Sinha

Representation of Algorithms
 As programs
 As flowcharts
 As pseudocodes

When an algorithm is represented in the form of a


programming language, it becomes a program

Thus, any program is an algorithm, although the


reverse is not true

Ref. Page 204 Chapter 11: Planning the Computer Program Slide 10/50
Computer Fundamentals: Pradeep K. Sinha & Priti Sinha

Flowcharts

Chapter 10: Computer Software Slide 11/36


Computer Fundamentals: Pradeep K. Sinha & Priti Sinha

What is a Flowchart?
 Flowchart is a pictorial representation of an algorithm
 Programmers often use it as a program-planning tool
 It uses boxes of different shapes to denote different types
of instructions
 Process of drawing a flowchart for an algorithm is known as
flowcharting

Ref. Page 205 Chapter 11: Planning the Computer Program Slide 12/50
Computer Fundamentals: Pradeep K. Sinha & Priti Sinha

Why Use Flowcharts?


 Algorithm is first represented as a flowchart
 Flowchart is then expressed in a programming language
 Main advantages of this two-step approach in program
writing are:
 While drawing a flowchart, a programmer can concentrate fully
on the logic of the solution
 Since a flowchart shows the flow of operations in pictorial form,
a programmer can detect any error in the logic
 Once the flowchart is ready, the programmer can concentrate
on coding the operations in each box of the flowchart as
statements of the programming language

(Continued on next slide…)

Ref. Page 205 Chapter 11: Planning the Computer Program Slide 13/50
Computer Fundamentals: Pradeep K. Sinha & Priti Sinha

Why Use Flowcharts?

 This two-step approach ensures an error-free


program
 It is a good practice to have a flowchart along with a
computer program because the flowchart often
serves as a document for the computer program

Ref. Page 205 Chapter 11: Planning the Computer Program Slide 14/50
Computer Fundamentals: Pradeep K. Sinha & Priti Sinha

Basic Flowchart Symbols

Terminal Input/Output Processing

Decision Flow lines Connectors

Ref. Page 206 Chapter 11: Planning the Computer Program Slide 15/50
Computer Fundamentals: Pradeep K. Sinha & Priti Sinha

Examples of Decision Symbol

No A<B Compare A>B


Is I = 10?
A&B

Yes A=B

(a) A two-way branch decision. (b) A three-way branch decision.

(Continued on next slide…)

Ref. Page 207 Chapter 11: Planning the Computer Program Slide 16/50
Computer Fundamentals: Pradeep K. Sinha & Priti Sinha

Examples of Decision Symbol

I=?

=0 =1 =2 =3 =4 =5 = Other

(c) A multiple-way branch decision.

Ref. Page 207 Chapter 11: Planning the Computer Program Slide 17/50
Computer Fundamentals: Pradeep K. Sinha & Priti Sinha

Sample Flowchart (Example 3)


A student appears in an examination, which consists of
total 10 subjects, each subject having maximum marks
of 100.
The roll number of the student, his/her name, and the
marks obtained by him/her in various subjects are
supplied as input data.
Such a collection of related data items, which is treated
as a unit is known as a record.
Draw a flowchart for the algorithm to calculate the
percentage marks obtained by the student in this
examination and then to print it along with his/her roll
number and name.

(Continued on next slide…)

Ref. Page 207 Chapter 11: Planning the Computer Program Slide 18/50
Computer Fundamentals: Pradeep K. Sinha & Priti Sinha

Sample Flowchart (Example 3)


Start

Read input data

Add marks of all


subjects giving Total

Percentage = Total / 10

Write output data

Stop

Ref. Page 208 Chapter 11: Planning the Computer Program Slide 19/50
Computer Fundamentals: Pradeep K. Sinha & Priti Sinha

Sample Flowchart (Example 4)


50 students of a class appear in the examination of
Example 3.
Draw a flowchart for the algorithm to calculate and print
the percentage marks obtained by each student along
with his/her roll number and name.

(Continued on next slide…)

Ref. Page 208 Chapter 11: Planning the Computer Program Slide 20/50
Computer Fundamentals: Pradeep K. Sinha & Priti Sinha

Sample Flowchart (Example 4)


Start

Read input data

Add marks of all Flowchart for the solution


subjects giving Total of Example 4 with an
infinite (endless) process
loop.
Percentage = Total / 10

Write output data

(Continued on next slide…)

Ref. Page 209 Chapter 11: Planning the Computer Program Slide 21/50
Computer Fundamentals: Pradeep K. Sinha & Priti Sinha

Sample Flowchart (Example 4)


Start

Count = 0

Read input data

Add marks of all subjects giving Total

Percentage = Total/10

Write output data


Flowchart for the solution
Add 1 to Count
of Example 4.
No
Is Count = 50?
Yes
Stop
(Continued on next slide…)

Ref. Page 210 Chapter 11: Planning the Computer Program Slide 22/50
Computer Fundamentals: Pradeep K. Sinha & Priti Sinha

Sample Flowchart (Example 4)


Start

Read input data

Yes
Is Rollno = 0000000?
Generalized flowchart
No for the solution of
Add marks of all subjects Example 4 using the
Stop
giving Total concept of trailer
record. Here the
process loop is
Percentage = Total / 10 terminated by detecting
a special non-data
record.
Write output data

Ref. Page 210 Chapter 11: Planning the Computer Program Slide 23/50
Computer Fundamentals: Pradeep K. Sinha & Priti Sinha

Sample Flowchart (Example 5)


For the examination of Example 3, we want to make a
list of only those students who have passed (obtained
30% or more marks) in the examination.
In the end, we also want to print out the total number of
students who have passed.
Assuming that the input data of all the students is
terminated by a trailer record, which has sentinel value
of 9999999 for Rollno, draw a flowchart for the
algorithm to do this.

(Continued on next slide…)

Ref. Page 210 Chapter 11: Planning the Computer Program Slide 24/50
Computer Fundamentals: Pradeep K. Sinha & Priti Sinha

Sample Flowchart (Example 5)


Start
Count = 0

Read input data

Yes
Is Rollno = 9999999?
No Write Count

Add marks of all subjects giving Total Stop

Percentage = Total/10
No
Is Percentage = > 30?
Yes
Write output data

Add 1 to Count

Ref. Page 211 Chapter 11: Planning the Computer Program Slide 25/50
Computer Fundamentals: Pradeep K. Sinha & Priti Sinha

Sample Flowchart (Example 6)


Suppose the input data of each student for the examination of
Example 3 also contains information regarding the sex of the
candidate in the field named Sexcode having values M (for
male) or F (for female).
We want to make a list of only those female students who have
passed in second division (obtained 45% or more but less than
60% marks).
In the end, we also want to print out the total number of such
students.
Assuming that the input data of all the students is terminated
by a trailer record, which has a sentinel value of Z for Sexcode,
draw a flowchart for the algorithm to do this.

Ref. Page 212 Chapter 11: Planning the Computer Program Slide 26/50
Computer Fundamentals: Pradeep K. Sinha & Priti Sinha

Sample Flowchart (Example 6)


Start

Count = 0

1 Read input data

Yes 2
Is Sexcode = Z?

No

1 No Is Sexcode = F?

Yes
Add marks of all subjects giving Total

Percentage = Total / 10

3
(Continued on next slide…)

Chapter 11: Planning the Computer Program Slide 27/50


Ref. Page 214
Computer Fundamentals: Pradeep K. Sinha & Priti Sinha

Sample Flowchart (Example 4)


3

No
1 Is Percentage = > 45?

Yes
2
No
1 Is Percentage < 60?

Write Count
Yes
Write output data
Stop

Add 1 to Count

Ref. Page 214 Chapter 11: Planning the Computer Program Slide 28/50
Computer Fundamentals: Pradeep K. Sinha & Priti Sinha

Levels of Flowchart

 Flowchart that outlines the main segments of a program


or that shows less details is a macro flowchart

 Flowchart with more details is a micro flowchart, or


detailed flowchart

 There are no set standards on the amount of details that


should be provided in a flowchart

Ref. Page 215 Chapter 11: Planning the Computer Program Slide 29/50
Computer Fundamentals: Pradeep K. Sinha & Priti Sinha

Example of Micro Flowchart

Part of a macro 1
flowchart
A micro
I=1
Flowchart
Total = 0

Total = Total + Marks (I)


Add marks of all
subjects giving Total
I=I+1

No
Is I > 10?
Yes
1

Ref. Page 215 Chapter 11: Planning the Computer Program Slide 30/50
Computer Fundamentals: Pradeep K. Sinha & Priti Sinha

Flowcharting Rules
 First chart the main line of logic, then incorporate detail

 Maintain a consistent level of detail for a given flowchart

 Do not chart every detail of the program. A reader who is


interested in greater details can refer to the program itself

 Words in the flowchart symbols should be common


statements and easy to understand

(Continued on next slide…)

Ref. Page 215 Chapter 11: Planning the Computer Program Slide 31/50
Computer Fundamentals: Pradeep K. Sinha & Priti Sinha

Flowcharting Rules

 Be consistent in using names and variables in the


flowchart

 Go from left to right and top to bottom in


constructing flowcharts

 Keep the flowchart as simple as possible. Crossing of


flow lines should be avoided as far as practicable

 If a new flowcharting page is needed, it is


recommended that the flowchart be broken at an
input or output point.

 Properly labeled connectors should be used to link


the portions of the flowchart on different pages

Ref. Page 215 Chapter 11: Planning the Computer Program Slide 32/50
Computer Fundamentals: Pradeep K. Sinha & Priti Sinha

Advantages of Flowcharts

 Better communication
 Flowchart is a pictorial representation of a program
 Effective analysis
 Macro flowchart, which charts the main line of logic of a
software system, becomes the system’s model
 Effective synthesis
 Group of programmers are associated with the design of a big
software system
 Each programmer is responsible for designing only a part of
the entire system
 Flowcharts of all programmers put together can help visualize
the overall system design

(Continued on next slide…)

Ref. Page 216 Chapter 11: Planning the Computer Program Slide 33/50
Computer Fundamentals: Pradeep K. Sinha & Priti Sinha

Advantages of Flowcharts
 Proper program documentation
 Documentation involves collecting, organizing, storing, and
maintaining a complete historical record of programs, and other
documents associated with a system
 Flowcharts often provide valuable documentation support
 Efficient coding
 Once a flowchart is ready, programmers find it very easy to write
the corresponding program because the flowchart acts as a road
map
 Systematic debugging
 Flowchart is very helpful in detecting, locating, and removing
mistakes (bugs) in a program in a systematic manner
 Systematic testing
 Flowchart is very helpful in designing test data for systematic
testing of programs

Ref. Page 216 Chapter 11: Planning the Computer Program Slide 34/50
Computer Fundamentals: Pradeep K. Sinha & Priti Sinha

Limitations of Flowchart

 Flowcharts are very time consuming and laborious to


draw (especially for large complex programs)
 Redrawing a flowchart for incorporating changes/
modifications is a tedious task
 There are no standards determining the amount of detail
that should be included in a flowchart

Ref. Page 217 Chapter 11: Planning the Computer Program Slide 35/50
Computer Fundamentals: Pradeep K. Sinha & Priti Sinha

Pseudocode

Chapter 10: Computer Software Slide 36/36


Computer Fundamentals: Pradeep K. Sinha & Priti Sinha

What is Pseudocode?
 Pseudocode is another program-planning tool used for
planning program logic
 “Pseudo” means imitation or false and “Code” refers to the
instructions written in a programming language
 Pseudocode is an imitation of actual computer instructions
 Pseudo-instructions are phrases written in a natural language
 Pseudocode uses a structure that resembles computer
instructions
 A programmer can concentrate solely on developing the logic
of a program without worrying about the syntax
 He/she can convert the pseudocode easily into a suitable
programming language

Ref. Page 217 Chapter 11: Planning the Computer Program Slide 37/50
Computer Fundamentals: Pradeep K. Sinha & Priti Sinha

Basic Logic (Control) Structures


Any program logic can be expressed by using only
following three simple logic structures:

1. Sequence logic,
2. Selection logic, and
3. Iteration (or looping) logic

Programs structured by using only these three logic


structures are called structured programs, and the
technique of writing such programs is known as
structured programming

Ref. Page 218 Chapter 11: Planning the Computer Program Slide 38/50
Computer Fundamentals: Pradeep K. Sinha & Priti Sinha

Sequence Logic
It is used for performing instructions one after another
in sequence.

Process 1

Process 1
Process 2
Process 2

(a) Flowchart (b) Pseudocode

Ref. Page 218 Chapter 11: Planning the Computer Program Slide 39/50
Computer Fundamentals: Pradeep K. Sinha & Priti Sinha

Selection Logic
• Also known as decision logic, it is used for making
decisions

• Three popularly used selection logic structures are


1. IF…THEN…ELSE
2. IF…THEN
3. CASE

Ref. Page 219 Chapter 11: Planning the Computer Program Slide 40/50
Computer Fundamentals: Pradeep K. Sinha & Priti Sinha

Selection Logic (IF…THEN…ELSE Structure)

Yes No IF Condition
IF (condition)
THEN Process 1
THEN ELSE ELSE Process 2

Process 1 Process 2
ENDIF

(a) Flowchart (b) Pseudocode

Ref. Page 219 Chapter 11: Planning the Computer Program Slide 41/50
Computer Fundamentals: Pradeep K. Sinha & Priti Sinha

Selection Logic (IF…THEN Structure)

Yes No
IF (condition)
IF Condition

THEN
THEN Process 1
Process 1
ENDIF

(a) Flowchart (b) Pseudocode

Ref. Page 219 Chapter 11: Planning the Computer Program Slide 42/50
Computer Fundamentals: Pradeep K. Sinha & Priti Sinha

Selection Logic (CASE Structure)

Yes
Type 1 Process 1

No
Yes
Type 2 Process 2 CASE Type

Case Type 1: Process 1


No
Case Type 2: Process 2

Yes
Type n Process n
Case Type n: Process n
No
ENDCASE

(a) Flowchart
(b) Pseudocode

Ref. Page 220 Chapter 11: Planning the Computer Program Slide 43/50
Computer Fundamentals: Pradeep K. Sinha & Priti Sinha

Iteration (or Looping) Logic

 Used to produce loops in program logic when one or


more instructions may be executed several times
depending on some conditions

 Two popularly used iteration logic structures are

1. DO…WHILE
2. REPEAT…UNTIL

Ref. Page 220 Chapter 11: Planning the Computer Program Slide 44/50
Computer Fundamentals: Pradeep K. Sinha & Priti Sinha
Iteration (or Looping) Logic
(DO…WHILE Structure)

False
Condition?

True
Process 1 DO WHILE Condition
Process 1
Block
Process n
Process n ENDDO

(a) Flowchart (b) Pseudocode

Ref. Page 221 Chapter 11: Planning the Computer Program Slide 45/50
Computer Fundamentals: Pradeep K. Sinha & Priti Sinha
Iteration (or Looping) Logic
(REPEAT…UNTIL Structure)

Process 1

REPEAT
Process 1
Process n

Process n
False
Condition? UNTIL Condition

True
(a) Flowchart (b) Pseudocode

Ref. Page 221 Chapter 11: Planning the Computer Program Slide 46/50
Computer Fundamentals: Pradeep K. Sinha & Priti Sinha

Sample Pseudocode (for Example 6)

Set Count to zero


Read first student record
DO WHILE Sexcode is not equal to Z
IF Sexcode = F THEN
Calculate Percentage
IF Percentage = > 45 THEN
IF Percentage < 60 THEN
Write output data
Add 1 to Count
ENDIF
ENDIF
ENDIF
Read next student record
ENDDO
Write Count
Stop

Ref. Page 222 Chapter 11: Planning the Computer Program Slide 47/50
Computer Fundamentals: Pradeep K. Sinha & Priti Sinha

Advantages of Pseudocode
 Converting a pseudocode to a programming language
is much more easier than converting a flowchart to a
programming language

 As compared to a flowchart, it is easier to modify the


pseudocode of a program logic when program
modifications are necessary

 Writing of pseudocode involves much less time and


effort than drawing an equivalent flowchart as it has
only a few rules to follow

Ref. Page 222 Chapter 11: Planning the Computer Program Slide 48/50
Computer Fundamentals: Pradeep K. Sinha & Priti Sinha

Limitations of Pseudocode

 In case of pseudocode, a graphic representation of


program logic is not available

 There are no standard rules to follow in using


pseudocode

 Different programmers use their own style of writing


pseudocode and hence communication problem
occurs due to lack of standardization

 For a beginner, it is more difficult to follow the logic


of or write pseudocode, as compared to flowcharting

Ref. Page 223 Chapter 11: Planning the Computer Program Slide 49/50
Computer Fundamentals: Pradeep K. Sinha & Priti Sinha

Key Words/Phrases

 Algorithm
 Basic logic structures
 Control structures
 Flowchart
 Iteration logic
 Looping logic
 Micro flowchart
 Macro flowchart
 Pseudocode
 Program Design Language (PDL)
 Sequence logic
 Selection logic
 Sentinel value
 Structured programming
 Trailer record

Chapter 11: Planning the Computer Program Slide 50/50


Computer Fundamentals: Pradeep K. Sinha & Priti Sinha

Computer Fundamentals

Pradeep K. Sinha
Priti Sinha

Chapter 12

Computer
Chapter 12: Computer Languages
Languages Slide 1/65
Computer Fundamentals: Pradeep K. Sinha & Priti Sinha

Learning Objectives

In this chapter you will learn about:


 Computer languages or programming languages
 Three broad categories of programming languages –
machine, assembly, and high-level languages
 Commonly used programming language tools such as
assembler, compiler, linker, and interpreter
 Concepts of object-oriented programming languages
 Some popular programming languages such as
FORTRAN, COBOL, BASIC, Pascal, C, C++, C#, Java,
Python, LISP and SNOBOL
 Related concepts such as Subprogram, Characteristics of
a good programming language, and factors to consider
while selecting a language for coding an application

Chapter 12: Computer Languages Slide 2/65


Computer Fundamentals: Pradeep K. Sinha & Priti Sinha

Analogy with
Natural Languages

Chapter 12: Computer Languages Slide 3/65


Computer Fundamentals: Pradeep K. Sinha & Priti Sinha

Analogy with Natural Languages

 Language is a means of communication


 Programmer uses a computer language to instruct a computer
what he/she wants it to do
 Set of words allowed in a language is called its vocabulary
 Each word in the vocabulary has a definite unambiguous
meaning
 Most computer languages use a very limited vocabulary
 Words and symbols of a computer language must be used as
per the set rules, known as syntax rules

Ref. Page 226 Chapter 12: Computer Languages Slide 4/65


Computer Fundamentals: Pradeep K. Sinha & Priti Sinha

Broad Classification of Computer Languages

 Machine language
 Assembly language
 High-level language

Ref. Page 227 Chapter 12: Computer Languages Slide 5/65


Computer Fundamentals: Pradeep K. Sinha & Priti Sinha

Machine Language

Chapter 12: Computer Languages Slide 6/65


Computer Fundamentals: Pradeep K. Sinha & Priti Sinha

Machine Language

 Machine language programs are written normally as strings


of binary 1s and 0s
 Circuitry of a computer is wired in a manner that it
recognizes the machine language instructions and converts
them into electrical signals needed to execute them
 A machine language instruction normally has a two-part
format: operation code tells the computer what function to
perform, and operand tells where to find or store the data

OPCODE OPERAND
(operation code) (address/location)

Instruction format
(Continued on next slide…)

Ref. Page 227 Chapter 12: Computer Languages Slide 7/65


Computer Fundamentals: Pradeep K. Sinha & Priti Sinha

Machine Language

 Every computer has a set of operation codes called its


instruction set
 Typical operations included in the instruction set are:
 Arithmetic operations
 Logical operations
 Branch operations
 Data movement operations between memory locations and
registers
 Data movement operations from/to input/output devices

Ref. Page 227 Chapter 12: Computer Languages Slide 8/65


Computer Fundamentals: Pradeep K. Sinha & Priti Sinha

A Sample Machine Language Program

001000000000001100111001 10001471
001100000000010000100001 14002041
011000000000011100101110 30003456
101000111111011100101110 50773456
000000000000000000000000 00000000

In Binary In Decimal
(Difficult to read and understand) (Easier to read and understand)

Ref. Page 228 Chapter 12: Computer Languages Slide 9/65


Computer Fundamentals: Pradeep K. Sinha & Priti Sinha
Advantages & Limitations of
Machine Language

Advantage

 Can be executed very fast

Limitations

 Machine dependent
 Difficult to program
 Error prone
 Difficult to modify

Ref. Page 228 Chapter 12: Computer Languages Slide 10/65


Computer Fundamentals: Pradeep K. Sinha & Priti Sinha

Assembly Language

Chapter 12: Computer Languages Slide 11/65


Computer Fundamentals: Pradeep K. Sinha & Priti Sinha

Assembly Language

 Assembly language programming helped in overcoming


limitations of machine language programming
 By using alphanumeric mnemonic codes instead of numeric
codes for instructions in instruction set
 Allowing use of alphanumeric names instead of numeric
addresses
 Providing additional instructions, called pseudo-instructions
 A language that allows use of letters and symbols instead of
numbers for representing instructions and storage locations is
called assembly language or symbolic language
 A program written in an assembly language is called assembly
language program or symbolic program

Ref. Page 229 Chapter 12: Computer Languages Slide 12/65


Computer Fundamentals: Pradeep K. Sinha & Priti Sinha

Sample Assembly Language Program

START PROGRAM AT 0000


START DATA AT 1000
SET ASIDE AN ADDRESS FOR FRST
SET ASIDE AN ADDRESS FOR SCND
SET ASIDE AN ADDRESS FOR ANSR
CLA FRST
ADD SCND
STA ANSR
HLT

Ref. Page 229 Chapter 12: Computer Languages Slide 13/65


Computer Fundamentals: Pradeep K. Sinha & Priti Sinha

Assembler

 We must convert an assembly language program into its


equivalent machine language program before executing it
 Translator program called assembler does this translation
 Assembler is system software supplied by computer
manufacturers

Assembly language Input Output Machine language


Assembler
program program

One-to-one correspondence
(Source program) (Object program)

Ref. Page 230 Chapter 12: Computer Languages Slide 14/65


Computer Fundamentals: Pradeep K. Sinha & Priti Sinha
Advantages of Assembly Language
Over Machine Language

 Easier to understand and use


 Easier to locate and correct errors
 Easier to modify
 No worry about addresses
 Easily relocatable
 Efficiency of machine language

Ref. Page 232 Chapter 12: Computer Languages Slide 15/65


Computer Fundamentals: Pradeep K. Sinha & Priti Sinha

Limitations of Assembly Language

 Machine dependent
 Knowledge of hardware required
 Machine level coding

Ref. Page 233 Chapter 12: Computer Languages Slide 16/65


Computer Fundamentals: Pradeep K. Sinha & Priti Sinha

Typical Uses of Assembly Language

 Mainly used today to fine-tune important parts of


programs written in a high-level language to improve
the program’s execution efficiency

Ref. Page 234 Chapter 12: Computer Languages Slide 17/65


Computer Fundamentals: Pradeep K. Sinha & Priti Sinha
Assembly Languages with
Macro Instructions

 Any assembly language instruction that gets translated


into several machine language instructions is called a
macro instruction
 Several assembly languages support such macro
instructions to speed up the coding process
 Assemblers of such assembly languages are designed to
produce multiple machine language instructions for each
macro instruction of the assembly language

Ref. Page 234 Chapter 12: Computer Languages Slide 18/65


Computer Fundamentals: Pradeep K. Sinha & Priti Sinha

High-level Language

Chapter 12: Computer Languages Slide 19/65


Computer Fundamentals: Pradeep K. Sinha & Priti Sinha

High-Level Languages

 Machine independent
 Do not require programmers to know anything about the
internal structure of computer on which high-level
language programs will be executed
 Deal with high-level coding, enabling the programmers
to write instructions using English words and familiar
mathematical symbols and expressions

Ref. Page 234 Chapter 12: Computer Languages Slide 20/65


Computer Fundamentals: Pradeep K. Sinha & Priti Sinha
Compiler

 Translator program (software) that translates a high-


level language program into its equivalent machine
language program
 Compiles a set of machine language instructions for
every program instruction in a high-level language

Ref. Page 235 Chapter 12: Computer Languages Slide 21/65


Computer Fundamentals: Pradeep K. Sinha & Priti Sinha

Compiler

Input Output
High-level language Compiler Machine language
program program

One-to-many correspondence
(Source program) (Object program)

Ref. Page 236 Chapter 12: Computer Languages Slide 22/65


Computer Fundamentals: Pradeep K. Sinha & Priti Sinha
Separate Compiler for Each High-level
Language Supported

Program P1 in high- Compiler for


level language L1 language L1 Machine code for P1

Program P2 in high- Compiler for


level language L2 language L2 Machine code for P2

A computer supporting languages L1 and L2

(Continued on next slide)

Ref. Page 236 Chapter 12: Computer Languages Slide 23/65


Computer Fundamentals: Pradeep K. Sinha & Priti Sinha
A High-level Language is Machine
Independent

Compiler for Machine code for


language L1 P1 that will run Executed on
on computer A on computer A computer A

Program P1 in high-
level language L1 Same results obtained

Compiler for Machine code for


language L1 P1 that will run Executed on
on computer B on computer B computer B

Ref. Page 237 Chapter 12: Computer Languages Slide 24/65


Computer Fundamentals: Pradeep K. Sinha & Priti Sinha

Syntax Errors

In addition to doing translation job, compilers also


automatically detect and indicate syntax errors

Syntax errors are typically of following types:

 Illegal characters
 Illegal combination of characters
 Improper sequencing of instructions in a program
 Use of undefined variable names

Note : A compiler cannot detect logic errors in a program

Ref. Page 237 Chapter 12: Computer Languages Slide 25/65


Computer Fundamentals: Pradeep K. Sinha & Priti Sinha
The Process of Removing Syntax Errors
From A Source Program
START

Edit
source program
Source program
Compile
source program

Syntax
No Generate
errors
detected? object program

Yes Object program


Generate list of coded STOP
error messages

Ref. Page 238 Chapter 12: Computer Languages Slide 26/65


Computer Fundamentals: Pradeep K. Sinha & Priti Sinha

Linker

 For a large software, storing all the lines of program


code in a single source file will be:

– Difficult to work with


– Difficult to deploy multiple programmers to
concurrently work towards its development
– Any change in the source program would require the
entire source program to be recompiled

 Hence, a modular approach is generally adapted to


develop large software where the software consists of
multiple source program files
 No need to write programs for some modules as it might
be available in library offering the same functionality
(Continued on next slide)

Ref. Page 238 Chapter 12: Computer Languages Slide 27/65


Computer Fundamentals: Pradeep K. Sinha & Priti Sinha

Linker

 Each source program file can be independently


modified and compiled to create a corresponding
object program file
 Linker program (software) is used to properly
combine all the object program files (modules)
 Creates the final executable program (load module)

Ref. Page 238 Chapter 12: Computer Languages Slide 28/65


Computer Fundamentals: Pradeep K. Sinha & Priti Sinha

Linker

Prog-1.src Prog-2.src Prog-n.src Source programs

Compilation
process
Prog-1.obj Prog-2.obj Prog-n.obj Object programs

Prog-i.lib Library modules

Linking
process

Executable Load module


program file

Ref. Page 238 Chapter 12: Computer Languages Slide 29/65


Computer Fundamentals: Pradeep K. Sinha & Priti Sinha

Interpreter

 Interpreter is a high-level language translator


 Takes one statement of a high-level language
program, translates it into machine language
instructions
 Immediately executes the resulting machine language
instructions
 Compiler simply translates the entire source program
into an object program and is not involved in its
execution

Ref. Page 239 Chapter 12: Computer Languages Slide 30/65


Computer Fundamentals: Pradeep K. Sinha & Priti Sinha

Interpreter

High-level Input Output Result of


Interpreter (translates and executes
language program
statement-by-statement)
program execution
(Source program)

Ref. Page 239 Chapter 12: Computer Languages Slide 31/65


Computer Fundamentals: Pradeep K. Sinha & Priti Sinha

Interpreter

 As compared to compilers, interpreters are easier to write


 The main advantage of interpreters over compilers is that an
interpreter flags a syntax error in a program statement to a
programmer as soon as it interprets the program statement
 Main disadvantage of interpreters over compilers is that they
are slower than compilers
 To combine the advantages of both interpreters and
compilers, computer system provides both a compiler and an
interpreter for a high-level language
 Assemblers, compilers, and interpreters are also referred to
as language processors

Ref. Page 239 Chapter 12: Computer Languages Slide 32/65


Computer Fundamentals: Pradeep K. Sinha & Priti Sinha
Intermediate Language Compiler &
Interpreter
 New type of compiler and interpreter combines the
speed, ease, and control of both compiler and
interpreter
 Compiler first compiles the source program to an
intermediate object program
 Intermediate object program is not a machine
language code but written in an intermediate
language that is virtually machine independent
 Interpreter takes intermediate object program,
converts it into machine language program and
executes it

Ref. Page 240 Chapter 12: Computer Languages Slide 33/65


Computer Fundamentals: Pradeep K. Sinha & Priti Sinha
Benefits of Intermediate Language
Compiler & Interpreter

 Intermediate object program is in compiled form and thus is


not original source code, so safer and easier to share
 Intermediate object program is based on a standard
Intermediate Definition Language (IDL)
 Interpreter can be written for any computer architecture and
operating system providing virtual machine environment to the
executing program
 Newer Interpreter compiles intermediate program, in memory,
into final host machine language program and executes it
 This technique is called Just-In-Time (JIT) Compilation

Ref. Page 240 Chapter 12: Computer Languages Slide 34/65


Computer Fundamentals: Pradeep K. Sinha & Priti Sinha

Advantages of High-Level Languages

 Machine independent
 Easier to learn and use
 Fewer errors during program development
 Lower program preparation cost
 Better documentation
 Easier to maintain

Ref. Page 240 Chapter 12: Computer Languages Slide 35/65


Computer Fundamentals: Pradeep K. Sinha & Priti Sinha

Limitations of High-Level Languages

 Lower execution efficiency


 Less flexibility to control the computer’s CPU, memory
and registers

Ref. Page 241 Chapter 12: Computer Languages Slide 36/65


Computer Fundamentals: Pradeep K. Sinha & Priti Sinha

Object-Oriented
Languages

Chapter 12: Computer Languages Slide 37/65


Computer Fundamentals: Pradeep K. Sinha & Priti Sinha
What is Object-Oriented Programming
(OOP)?

 Essence of OOP is to solve a problem by:


 Identifying the real-world objects of the problem and the
processing required of those objects
 Then creating simulations of those objects, their processes,
and the required communications between the objects
 OOP makes programming simpler, easier, and faster
 OOP philosophy is now used in almost all popular
programming languages

Ref. Page 242 Chapter 12: Computer Languages Slide 38/65


Computer Fundamentals: Pradeep K. Sinha & Priti Sinha

Fundamental Concepts of OOP


 Object
 An object is the primitive element of a program written in an
OOP language
 Each object consists of a set of procedures and some data
 Method
 A method of an object defines the set of operations that the
object will execute when it receives a message
 Methods are like function definitions
 Entire collection of methods of an object is called the message
protocol, or message interface
 Message
 Mechanism to support communication between objects is
through messages

Ref. Page 242 Chapter 12: Computer Languages Slide 39/65


Computer Fundamentals: Pradeep K. Sinha & Priti Sinha

Fundamental Concepts of OOP


 Class
 A class is a description of one or more similar objects
 A class can have multiple instances
 Each instance of a class is known as an object of the class
 Class variables are variables stored in the class whose values
are shared by all instances
 Instance variables are variables for which local storage is
available in the instances (objects)
 Inheritance
 Inheritance is a mechanism to share code and behavior
 A child class inherits all of the instance variables, instance
methods, and class methods of its parent class
 A child class can inherit from multiple parent classes. This is
called multiple inheritance

Ref. Page 243 Chapter 12: Computer Languages Slide 40/65


Computer Fundamentals: Pradeep K. Sinha & Priti Sinha
Example of Class, Instance, and
Inheritance

Person

Classes Male Female

Boy Man

Instances Ram Shyam Mohan Seeta Geeta

Ref. Page 244 Chapter 12: Computer Languages Slide 41/65


Computer Fundamentals: Pradeep K. Sinha & Priti Sinha
Example of Objects, Class, and
Inheritance
Object ‘a’
Class ‘A’ (Instance of ‘A’)
Variables of ‘A’ Class ‘A’

Methods of ‘A’ Instance variables of ‘A’

Class ‘B’
(Sub-class of Object ‘b’
Class ‘A’) (Instance of ‘B’)
Inherits from ‘A’ Class ‘B’

Variables of ‘B’ Inherited instance variables of ‘A’

Methods of ‘B’ Instance variables of ‘B’

Ref. Page 245 Chapter 12: Computer Languages Slide 42/65


Computer Fundamentals: Pradeep K. Sinha & Priti Sinha

Key Elements of Object-Oriented Paradigm

Sr.
Element Meaning
No.
1 Abstraction Abstraction means that an object’s characteristics are broken
into manageable chunks as defined and documented in its
class description.
2 Encapsulation Encapsulation stipulates that code and data are stored as one
unit. Encapsulation also enables selective or total information
hiding, since it can make portions of the code and data
inaccessible from outside the unit.
3 Modularity Modularity defines the unit reuse. These units group
abstractions together.
4 Hierarchy Hierarchy allows an object’s behaviors to be refined
(subclasses) without recoding of the parent object (the
superclass). Some OO languages allow an object to have
more than one superclass, a feature that is known as multiple
inheritance. Inheritance hierarchies enable ranking/ordering
of abstractions.
5 Messages Messages, similar in use to function calls, are requests to
perform an operation on an instantiated object.

Ref. Page 245 Chapter 12: Computer Languages Slide 43/65


Computer Fundamentals: Pradeep K. Sinha & Priti Sinha

Some High-level
Languages

Chapter 12: Computer Languages Slide 44/65


Computer Fundamentals: Pradeep K. Sinha & Priti Sinha

FORTRAN

 Stands for FORmula TRANslation


 Originally developed by John Backus and his team at
IBM followed by several revisions
 Standardized by ANSI as FORTRAN 77 and FORTRAN 90
 FORTRAN 2018 is the latest released version till date
 Designed for solving scientific & engineering problems
 Oriented towards solving problems of a mathematical
nature
 Popular language amongst scientists and engineers

Ref. Page 246 Chapter 12: Computer Languages Slide 45/65


Computer Fundamentals: Pradeep K. Sinha & Priti Sinha

COBOL

 Stands for COmmon Business Oriented Language


 Originally developed started under Grace Hopper
followed by COnference on DAta SYstems Languages
(CODASYL)
 Standardized by ANSI as COBOL 74, COBOL 85, and
COBOL 2002
 COBOL 2014 is the latest COBOL standard as on date
 Designed for programming business data processing
applications
 Designed to have the appearance and structure of a
business report written in English, hence often referred
to as a self-documenting language

Ref. Page 247 Chapter 12: Computer Languages Slide 46/65


Computer Fundamentals: Pradeep K. Sinha & Priti Sinha

BASIC

 Stands for Beginners All-purpose Symbolic Instruction


Code
 Developed by Professor John Kemeny and Thomas Kurtz
at Darmouth College in the United States
 Standardized by ANSI as BASIC 78
 Designed to be an interactive language and to use an
interpreter instead of a compiler
 Simple to implement, learn and use language. Hence, it
was a widely used language on personal computers
 Flexible and reasonably powerful language and can be
used for both business and scientific applications

Ref. Page 249 Chapter 12: Computer Languages Slide 47/65


Computer Fundamentals: Pradeep K. Sinha & Priti Sinha

Pascal

 Named after the famous seventeenth-century French


mathematician Blaise Pascal
 Developed by Professor Nicklaus Wirth of Federal
Institute of Technology in Zurich
 Encourages programmers to write well-structured,
modular programs, instills good programming practices
 Recognized as an educational language and is used to
teach programming to beginners
 Suitable for both scientific & business applications
 Has features to manipulate numbers, vectors, matrices,
strings, sets, records, files, and lists

Ref. Page 250 Chapter 12: Computer Languages Slide 48/65


Computer Fundamentals: Pradeep K. Sinha & Priti Sinha

 Developed in 1972 at AT&T’s Bell laboratories, USA


by Dennis Ritchie and Brian Kernighan
 Standardized by ANSI and ISO as C89, C90, C99
 High-level programming languages (mainly machine
independence) with the efficiency of an assembly
language
 Language of choice of programmers for portable
systems software and commercial software packages
like OS, compiler, spreadsheet, word processor, and
database management systems

Ref. Page 251 Chapter 12: Computer Languages Slide 49/65


Computer Fundamentals: Pradeep K. Sinha & Priti Sinha

C++ (C plus plus)

 Named C++ as ++ is increment operator and C


language is incremented to its next level with C++
 Developed by Bjarne Stroustrup at Bell Labs in the
early 1980s
 Contains all elements of the basic C language
 Expanded to include numerous object-oriented
programming features
 Provides a collection of predefined classes, along with
the capability of user-defined classes
 Being a superset of C, it is an extremely powerful and
efficient language. However, it is more difficult to learn
than C

Ref. Page 251 Chapter 12: Computer Languages Slide 50/65


Computer Fundamentals: Pradeep K. Sinha & Priti Sinha

Java

 Development started at Sun Microsystems in 1991 by a


team led by James Gosling
 Developed to be similar to C++ with fewer features to
keep it simple and easy to use
 Compiled code is machine-independent and developed
programs are simple to implement and use
 Uses just-in-time compilation
 Used in embedded systems such as hand-held devices,
telephones and VCRs
 Comes in two variants – Java Runtime Engine (JRE) and
Java Software Development Kit (SDK)

Ref. Page 253 Chapter 12: Computer Languages Slide 51/65


Computer Fundamentals: Pradeep K. Sinha & Priti Sinha

C# (C Sharp)

 Object-oriented programming language developed by


Anders Hejlsberg and released by Microsoft as part of
Microsoft’s .NET technology initiative
 Standardized by ECMA and ISO
 Syntactically and semantically very close to C++ and
adopts various object-oriented features from both C++
and Java
 Compilers target the Common Language Infrastructure
(CLI) implemented by Common Language Runtime (CLR)
of .NET Framework
 CLR provides important services such as, memory
management, exception handling, and security

Ref. Page 254 Chapter 12: Computer Languages Slide 52/65


Computer Fundamentals: Pradeep K. Sinha & Priti Sinha

Python

 A high level programming language, first released in 1991


by Guido van Rossum of Netherlands

 Being a Free and Open Source Software (FOSS), it has a


large, world-wide development community

 It is now managed by Python Software Foundation, a non-


profit community

 It now ranks among top ten popular programming


languages

Ref. Page 254 Chapter 12: Computer Languages Slide 53/65


Computer Fundamentals: Pradeep K. Sinha & Priti Sinha

Key Features of Python Include

 Simple to learn and easy to read and understand

 Both procedure-oriented and object-oriented programming is


possible

 Highly portable

 Interpreted language

 Extensible and embeddable language

 Rich library support

Ref. Page 255 Chapter 12: Computer Languages Slide 54/65


Computer Fundamentals: Pradeep K. Sinha & Priti Sinha

LISP

 Stands for LISt Processing


 Developed in 1959 by John McCarthy of MIT
 Designed to have features for manipulating non-
numeric data, such as symbols and strings of text
 Due to its powerful list processing capability, it is
extensively used in the areas of pattern recognition,
artificial intelligence, and for simulation of games
 Functional programming language in which all
computation is accomplished by applying functions to
arguments

Ref. Page 256 Chapter 12: Computer Languages Slide 55/65


Computer Fundamentals: Pradeep K. Sinha & Priti Sinha

SNOBOL

 Stands for StriNg Oriented symBOlic Language


 Used for non-numeric applications
 Powerful string manipulation features
 Widely used for applications in the area of text
processing

Ref. Page 256 Chapter 12: Computer Languages Slide 56/65


Computer Fundamentals: Pradeep K. Sinha & Priti Sinha

Selecting a Language for


Coding an Application

Chapter 12: Computer Languages Slide 57/65


Computer Fundamentals: Pradeep K. Sinha & Priti Sinha
Characteristics of a Good
Programming Language

 Simplicity
 Naturalness
 Abstraction
 Efficiency
 Structured Programming Support
 Compactness
 Locality
 Extensibility
 Suitability to its environment

Ref. Page 257 Chapter 12: Computer Languages Slide 58/65


Computer Fundamentals: Pradeep K. Sinha & Priti Sinha
Factors for Selecting a Language for
Coding an Application

 Nature of the application


 Familiarity with the language
 Ease of learning the language
 Availability of program development tools
 Execution efficiency
 Features of a good programming language

Ref. Page 258 Chapter 12: Computer Languages Slide 59/65


Computer Fundamentals: Pradeep K. Sinha & Priti Sinha

Subprogram

Chapter 12: Computer Languages Slide 60/65


Computer Fundamentals: Pradeep K. Sinha & Priti Sinha

Subprogram

 Program written in a manner that it can be brought into


use in other programs and used whenever needed
without rewriting
 Also referred to as subroutine, sub-procedure, or function
 Subprogram call statement contains the name of the
subprogram followed by a list of parameters enclosed
within a pair of parentheses
 Intrinsic subprograms (also called built-in-functions) are
those provided with the programming language
 Programmer-written subprograms are written and used
as and when they are needed

Ref. Page 258 Chapter 12: Computer Languages Slide 61/65


Computer Fundamentals: Pradeep K. Sinha & Priti Sinha

Structure of a Subprogram

Subprogram name Parameter

Subprogram header
sqrt (x)

Set of instructions that Subprogram body


perform the intended task

Ref. Page 259 Chapter 12: Computer Languages Slide 62/65


Computer Fundamentals: Pradeep K. Sinha & Priti Sinha

Flow of Control in Case of Subprogram Calls

1 2 subprogram header

subprogram call statement 6


next statement 4 3

subprogram body
7
5

subprogram call statement


next statement 8
9

A program that calls Flow of control A subprogram


the subprogram twice

Ref. Page 259 Chapter 12: Computer Languages Slide 63/65


Computer Fundamentals: Pradeep K. Sinha & Priti Sinha

Key Words/Phrases

 Assembler  Just-in-time compilation


 Assembly language  Language processor
 BASIC  Linker
 Built-in function  LISP
 C  Load module
 C++  Logic error
 C#  Low-level language
 COBOL  Machine language
 Coding  Macro instructions
 Compiler  Object program
 Computer language  Object-oriented programming
 FORTRAN  Opcode
 Function  Operand
 High-level language  Pascal
 HotJava Interpreter  Programmer
 Intrinsic subprogram  Programming
 Intermediate compiler and  Programming language
Interpreter  Pseudo instruction
 Java  Python
 Self-documenting language

(Continued on next slide)

Chapter 12: Computer Languages Slide 64/65


Computer Fundamentals: Pradeep K. Sinha & Priti Sinha

Key Words/Phrases

 SNOBOL
 Source program
 Sub-procedure
 Subprogram
 Subroutine
 Symbolic language
 Syntax error
 Syntax rules
 Programmer-written subprograms

Chapter 12: Computer Languages Slide 65/65


Computer Fundamentals: Pradeep K. Sinha & Priti Sinha
Computer Fundamentals
Computer Fundamentals
Dr. Pradeep K. Sinha & Priti Sinha

Pradeep K. Sinha
Priti Sinha

Chapter 13

Chapter 00
System
Implementation
Title
and Operation
Chapter 13: System Implementation and Operation Slide 1/35
Computer Fundamentals: Pradeep K. Sinha & Priti Sinha

Learning Objectives

In this chapter you will learn about:

 Main activities of implementation and operation


phase of software
 Software testing and debugging
 Software documentation
 Software deployment and changeover processes
 System evaluation and
 Software maintenance

Chapter 13: System Implementation and Operation Slide 2/35


Computer Fundamentals: Pradeep K. Sinha & Priti Sinha

Program Errors,
Testing and Debugging

Chapter 13: System Implementation and Operation Slide 3/35


Computer Fundamentals: Pradeep K. Sinha & Priti Sinha

Testing and Debugging

 Program errors are known as bugs


 Process of detecting and correcting these errors is called
debugging
 Testing is the process of making sure that the program
performs the intended task
 Debugging is the process of locating and eliminating
program errors

Ref. Page 263 Chapter 13: System Implementation and Operation Slide 4/35
Computer Fundamentals: Pradeep K. Sinha & Priti Sinha

Types of Program Errors


 Syntax errors
 Occurs when the rules or syntax of the programming
language are not followed
 For example, incorrect punctuation, incorrect word
sequence, undefined terms, and misuse of terms
 Syntax errors are detected by a language processor
 Logic errors
 Occurs due to errors in planning a program’s logic
 Such errors cause the program to produce incorrect
output.
 These errors cannot be detected by a language
processor

Ref. Page 264 Chapter 13: System Implementation and Operation Slide 5/35
Computer Fundamentals: Pradeep K. Sinha & Priti Sinha

Testing of a Program

 Testing procedure involves running program to


process input test data, and comparing obtained
results with correct results
 Test data must test each logical function of the
program, and should include all types of possible
valid and invalid data

Ref. Page 264 Chapter 13: System Implementation and Operation Slide 6/35
Computer Fundamentals: Pradeep K. Sinha & Priti Sinha

Debugging a Program for Syntax Errors

 Relatively easier to detect and correct syntax errors


than logic errors in a program
 Language processors are designed to automatically
detect syntax errors
 Single syntax error often causes multiple error
messages to be generated by the language processor
 Removal of the syntax error will result in the removal
of all associated error messages

Ref. Page 265 Chapter 13: System Implementation and Operation Slide 7/35
Computer Fundamentals: Pradeep K. Sinha & Priti Sinha

Debugging a Program for Logic Errors

 Logic errors are more difficult to detect than syntax


errors as computer does not produce any error
message for such errors
 One or more of following methods are commonly used
for locating logic errors:
 Doing hand simulation of the program code
 Putting print statements in the program code
 Using a debugger (a software tool that assists a
programmer in following the program’s execution
step-by-step)
 Using memory dump (printout of the contents of
main memory and registers)

Ref. Page 265 Chapter 13: System Implementation and Operation Slide 8/35
Computer Fundamentals: Pradeep K. Sinha & Priti Sinha

Unit and Integrated Testing

 In unit testing, each module of software is tested


independently for its functionality by the programmer
who developed the module.
 In integrated testing, the team integrates the
independently developed and tested modules into a
compete system, and tests the integrated system to
check if all modules coordinate properly.

Ref. Page 266 Chapter 13: System Implementation and Operation Slide 9/35
Computer Fundamentals: Pradeep K. Sinha & Priti Sinha

Alpha and Beta Testing

 Software internally released for testing is known as


alpha version and the test conducted on it is called
alpha testing
 Software released for additional testing to a selected
set of external users is beta version and test
conducted on it called is beta testing

Ref. Page 266 Chapter 13: System Implementation and Operation Slide 10/35
Computer Fundamentals: Pradeep K. Sinha & Priti Sinha

Difference Between Testing and Debugging

Sr. No. Testing Debugging


1  Testing is the process of  Debugging is the process of
validating the correctness of eliminating errors in a program
a program
 Its objective is to detect the cause of
 Its objective is to error and remove known errors in the
demonstrate that the program
program meets its design
specifications

2  Testing is complete when all  Debugging is complete when all known


desired verifications against errors in the program are fixed
specifications are completed
 Note that debugging process ends only
temporarily because it restarts
whenever a new error is detected in
the program

(Continued on next slide)

Ref. Page 266 Chapter 13: System Implementation and Operation Slide 11/35
Computer Fundamentals: Pradeep K. Sinha & Priti Sinha

Difference Between Testing and Debugging

Sr. No. Testing Debugging


3  Testing is a definable process  Debugging being a reactive process cannot
which can and should be be planned ahead of time
planned and scheduled
properly  It is carried out whenever errors are
detected in a program

4  Testing can begin in the early  Debugging can begin only after the program
stages of software is ready
development.
 The approach used for debugging largely
 Although the test runs of a depends on the personal choice of the
program are carried out only programmer and the type of error in the
after the program is coded, program
but the decision of what to
test, how to test, and with
what kind of data to test, can
and should be done before
the coding is started

Ref. Page 267 Chapter 13: System Implementation and Operation Slide 12/35
Computer Fundamentals: Pradeep K. Sinha & Priti Sinha

Software Documentation

Chapter 13: System Implementation and Operation Slide 13/35


Computer Fundamentals: Pradeep K. Sinha & Priti Sinha

What is Documentation?

 It is the process of collecting, organizing, storing, and


maintaining a complete historical record of programs and
other documents used or prepared during the different
phases of the life cycle of software
 It is an on-going process that starts as early as in the study
phase of the software and continues until its
implementation and operation phase
 Maintenance team has to carry out documentation from
time-to-time, whenever it modifies the software

Ref. Page 267 Chapter 13: System Implementation and Operation Slide 14/35
Computer Fundamentals: Pradeep K. Sinha & Priti Sinha

Need for Documentation

 Solves the problem of indispensability of an individual for an


organization
 Makes software easier to modify and maintain in future
 Helps in restarting a software project postponed earlier due
to some reason

Ref. Page 267 Chapter 13: System Implementation and Operation Slide 15/35
Computer Fundamentals: Pradeep K. Sinha & Priti Sinha

Forms of Documentation
 Requirement specification document
 Before developing some software, the development team
must analyze its requirements and document them
 Requirement specification document is an outcome of this
exercise
 Specifies the objectives of developing the software and its
usefulness to various categories of users
 Specifies the functionalities, capabilities, performance, inputs,
and outputs requirements of the software
 Specifies what all the software will do when developed
 Design document
 Defines overall architecture of the software
 Specifies various hardware and software components of the
software and interfaces between the components
(Continued on next slide…)

Ref. Page 268 Chapter 13: System Implementation and Operation Slide 16/35
Computer Fundamentals: Pradeep K. Sinha & Priti Sinha

Forms of Documentation

 Includes a hierarchy of software components, rules for


component selection, and interfaces between the components
 Comments
 From maintenance point of view, comments are necessary
 All high-level languages provide the facility to write comments
in the source code of a program
 Use of this facility by programmers for proper documentation
of their programs is highly recommended
 Comments should be used intelligently to improve the quality
and understandability
 Comments should not be redundant, incorrect, incomplete, or
written in a manner that is difficult to understand

(Continued on next slide…)

Ref. Page 269 Chapter 13: System Implementation and Operation Slide 17/35
Computer Fundamentals: Pradeep K. Sinha & Priti Sinha

Forms of Documentation
 System manual
 Standard system manuals contain the following information:
 Specific module names along with their description and
purpose
 Detailed system flow charts and program flow charts for each
module
 Description of the program listings and the control procedures
 Source listing of all the programs with full details of all
modifications
 Specifications of all input and output media
 Specimen of all types of input and output
 File layout
 Structure and description of all test data, test results, storage
dumps, trace program printouts, etc. (Continued on next slide…)

Ref. Page 269 Chapter 13: System Implementation and Operation Slide 18/35
Computer Fundamentals: Pradeep K. Sinha & Priti Sinha

Forms of Documentation
 User manual
 User manual describes how to use the software
 User manual must contain following information:
 Installation and operational details of software
 Loading and unloading procedures
 Starting, running, and terminating procedures
 Description and example of any control statements used
 All console commands with errors and console messages, their
meaning, reply, and/or operation action
 List of error conditions with explanation for their re-entry into the
system
 List of programs, which users must execute before and after
execution of each program
 Special checks (if any) and security measures, etc.
(Continued on next slide…)

Ref. Page 269 Chapter 13: System Implementation and Operation Slide 19/35
Computer Fundamentals: Pradeep K. Sinha & Priti Sinha

Forms of Documentation

 Commonly used ways to describe each feature of


software in a user manual are:
 Commands/Functions list
 It lists the commands or functions of the software alphabetically
or grouped logically
 Tutorial
 It contains tutorials for various functionalities or tasks of software
 Online help
 It contains online information, which users can use whenever
needed while using the software without the need to refer to any
other document

Ref. Page 270 Chapter 13: System Implementation and Operation Slide 20/35
Computer Fundamentals: Pradeep K. Sinha & Priti Sinha

Forms of Documentation

 Marketing document: It consists of the following:


 Usefulness of the software product
 Its salient features
 Its comparison with other competing products
 Its system requirements (hardware, operating system, etc.)

Ref. Page 270 Chapter 13: System Implementation and Operation Slide 21/35
Computer Fundamentals: Pradeep K. Sinha & Priti Sinha

Documentation Standard

It deals with:

 How to do documentation?
 How to choose meaningful program variable names?
 How to design the GUI?
 How and up to what detail to include comments?
 What diagrams, charts, reports, outputs, etc. are
necessary for completing documentation?

Ref. Page 270 Chapter 13: System Implementation and Operation Slide 22/35
Computer Fundamentals: Pradeep K. Sinha & Priti Sinha

Software Deployment

Chapter 13: System Implementation and Operation Slide 23/35


Computer Fundamentals: Pradeep K. Sinha & Priti Sinha

Changeover to the New System

 When a software is ready for use, it is deployed at site for use


by the intended users
 At this stage, a changeover from the old system of operation
to the new system takes place
 Three normally followed methods to carry out the changeover
process are:
 Immediate changeover
 Parallel run
 Phased conversion

(Continued on next slide)

Ref. Page 271 Chapter 13: System Implementation and Operation Slide 24/35
Computer Fundamentals: Pradeep K. Sinha & Priti Sinha

Changeover to the New System

Old system in New system in


operation operation

Old system New system

Cut-off date

Time

(a) Immediate changeover

(Continued on next slide)

Ref. Page 272 Chapter 13: System Implementation and Operation Slide 25/35
Computer Fundamentals: Pradeep K. Sinha & Priti Sinha

Changeover to the New System


Old system
in operation
New
system in
operation

Overlapping period of
complete operation of
Old system
both the old and the new
systems

New system

Time

(b) Parallel run (Continued on next slide)

Ref. Page 272 Chapter 13: System Implementation and Operation Slide 26/35
Computer Fundamentals: Pradeep K. Sinha & Priti Sinha

Changeover to the New System


Old system Old and new systems New system
completely in operation in parts completely
operational operational

Old system

New system

Time

(c) Phased conversion

Ref. Page 272 Chapter 13: System Implementation and Operation Slide 27/35
Computer Fundamentals: Pradeep K. Sinha & Priti Sinha

System Evaluation

Chapter 13: System Implementation and Operation Slide 28/35


Computer Fundamentals: Pradeep K. Sinha & Priti Sinha

System Evaluation

 Process of evaluating a system (after it is put in


operation) to verify whether or not it is meeting its
objectives
 Points normally considered for evaluating a system are:
 Performance evaluation
 Cost analysis
 Time analysis
 User satisfaction
 Ease of modification
 Failure rate

Ref. Page 273 Chapter 13: System Implementation and Operation Slide 29/35
Computer Fundamentals: Pradeep K. Sinha & Priti Sinha

Software Maintenance

Chapter 13: System Implementation and Operation Slide 30/35


Computer Fundamentals: Pradeep K. Sinha & Priti Sinha

Definition

 Process of modifying software system or component after


deployment to correct faults, add functionality, improve
performance or other attributes, or adapt to a change in
environment

Ref. Page 274 Chapter 13: System Implementation and Operation Slide 31/35
Computer Fundamentals: Pradeep K. Sinha & Priti Sinha

Need for Software Maintenance

 Any software needs modification from time-to-time due to


one or more of the following reasons:
 Changes in business conditions or operations of the
organization
 Changes in organizational policies or enforcement of new laws
 Changes in user needs
 Changes in technology

Ref. Page 274 Chapter 13: System Implementation and Operation Slide 32/35
Computer Fundamentals: Pradeep K. Sinha & Priti Sinha

Importance of Software Maintenance

 Maintenance is an important phase in SDLC


 On an average, maintenance cost of software systems is two
to four times the development cost

Ref. Page 274 Chapter 13: System Implementation and Operation Slide 33/35
Computer Fundamentals: Pradeep K. Sinha & Priti Sinha

Controlling Modifications

 Frequent change is disrupting and disturbing


 Some control over changes is required for which a change
control board is constituted
 Change control board evaluates all requests for change and
approves major changes
 It need not approve normal maintenance operations
 Major changes are those that alter the system significantly
 Whenever a programmer modifies a program, the concerned
members must also modify the associated documents

Ref. Page 274 Chapter 13: System Implementation and Operation Slide 34/35
Computer Fundamentals: Pradeep K. Sinha & Priti Sinha

Key Words/Phrases

 Alpha testing  System evaluation


 Beta testing  System manual
 Bugs  Testing
 Changeover operations  Unit testing
 Comments  User manual
 Debugger
 Debugging
 Documentation
 Immediate changeover
 Integrated testing
 Logic errors
 Memory dump
 Parallel run
 Phased conversion
 Software maintenance
 Syntax errors

Chapter 13: System Implementation and Operation Slide 35/35


Computer Fundamentals : Pradeep K. Sinha & Priti Sinha

Computer Fundamentals

Pradeep K. Sinha
Priti Sinha

Chapter 14

Operating Systems
Chapter 14: Operating Systems Slide 1/81
Computer Fundamentals : Pradeep K. Sinha & Priti Sinha

Learning Objectives
In this chapter you will learn about:
 Definition and need for operating system
 Main functions of an operating system
 Commonly used mechanisms for:
 Process management
 Memory management
 File management
 Device management
 Security
 Command interpretation
 Some commonly used OS capability enhancement software
 Some popular operating systems

Chapter 14: Operating Systems Slide 2/81


Computer Fundamentals : Pradeep K. Sinha & Priti Sinha

Definition, Need and


Functions of an OS

Chapter 14: Operating Systems Slide 3/81


Computer Fundamentals : Pradeep K. Sinha & Priti Sinha

Definition and Need for OS

 Integrated set of programs that controls the resources


(the CPU, memory, I/O devices, etc.) of a computer
system
 Provides its users with an interface or virtual machine
that is more convenient to use than the bare machine
 Two primary objectives of an OS are:
 Making a computer system convenient to use
 Managing the resources of a computer system

Ref. Page 277 Chapter 14: Operating Systems Slide 4/81


Computer Fundamentals : Pradeep K. Sinha & Priti Sinha

Logical Architecture of a Computer System

Users

Other system
software and application programs

Operating system

Computer hardware

Operating system layer hides details of hardware from


programmers and other users and provides them with a
convenient interface for using the system

Ref. Page 278 Chapter 14: Operating Systems Slide 5/81


Computer Fundamentals : Pradeep K. Sinha & Priti Sinha

Main Functions of an OS

 Process management
 Memory management
 File management
 Device management
 Security
 Command interpretation

Ref. Page 278 Chapter 14: Operating Systems Slide 6/81


Computer Fundamentals : Pradeep K. Sinha & Priti Sinha
Parameters for Measuring System
Performance

 Throughput: Amount of work that the system is able to


do per unit time
 Turnaround time: Interval from the time of submission
of a job to the system for processing to the time of
completion of the job
 Response time: Interval from the time of submission of a
job to the system for processing to the time the first
response for the job is produced by the system

Ref. Page 279 Chapter 14: Operating Systems Slide 7/81


Computer Fundamentals : Pradeep K. Sinha & Priti Sinha

Process Management

Chapter 14: Operating Systems Slide 8/81


Computer Fundamentals : Pradeep K. Sinha & Priti Sinha

Process Management

 A process (also called job) is a program in execution


 Process management module of an operating system
manages the processes submitted to a system in a
manner to minimize idle time of processors (CPUs, I/O
processors, etc.) of the system

Ref. Page 280 Chapter 14: Operating Systems Slide 9/81


Computer Fundamentals : Pradeep K. Sinha & Priti Sinha
Process Management Mechanisms in
Early Systems

 Manual loading mechanism: Jobs were manually


loaded one after another in a computer by the
computer operator
 Batch processing mechanism: Batch of jobs was
submitted together to the computer and job-to-job
transition was done automatically by the operating
system
 Job Control Language (JCL): Control statements
were used to identify a new job in a batch of jobs and
to determine its resource requirements

Ref. Page 280 Chapter 14: Operating Systems Slide 10/81


Computer Fundamentals : Pradeep K. Sinha & Priti Sinha
Use of Job Control Statements in Batch
Processing (An Example)

$END

Data for program

$RUN
$LOAD

COBOL program

$COBOL
$JOB, ONGC05839,
USER=SINHA

Ref. Page 281 Chapter 14: Operating Systems Slide 11/81


Computer Fundamentals : Pradeep K. Sinha & Priti Sinha

Uniprogramming

Main memory

Operating system OS area

User job User program


Execution in

area
progress

CPU

(Continued on next slide…)

Ref. Page 282 Chapter 14: Operating Systems Slide 12/81


Computer Fundamentals : Pradeep K. Sinha & Priti Sinha

Uniprogramming

 A job does not need CPU for entire duration of its processing
 Depending on CPU utilization during the course of processing,
jobs are of two types
 CPU-bound jobs, which mostly perform computations
with little I/O operations
 I/O-bound jobs, which mostly perform I/O operations
with little computation
 In a uniprogramming system, CPU is idle whenever the
currently executing job performs I/O operations

Ref. Page 282 Chapter 14: Operating Systems Slide 13/81


Computer Fundamentals : Pradeep K. Sinha & Priti Sinha

Multiprogramming

 Multiprogramming is interleaved execution of two or more


different and independent programs by a computer
 Multiprogramming enables two or more user programs to
reside simultaneously in main memory and carries out their
interleaved execution
 With multiple user programs residing simultaneously in main
memory, whenever a user program that was executing goes
to perform I/O operations, the operating system allocates CPU
to another user program in main memory
 In multiprogramming, several user programs share CPU time
to keep it busy
 Note that multiprogramming does not mean execution of
instructions from several programs simultaneously
(Continued on next slide…)

Ref. Page 282 Chapter 14: Operating Systems Slide 14/81


Computer Fundamentals : Pradeep K. Sinha & Priti Sinha

Multiprogramming

Main memory

Operating system
Writing output
data
Job A

Job B

Execution in Job C
progress (Waiting for CPU)

Secondary disk
storage
CPU

A typical scenario of jobs in a multiprogramming system

Ref. Page 283 Chapter 14: Operating Systems Slide 15/81


Computer Fundamentals : Pradeep K. Sinha & Priti Sinha

Multiprogramming

Job is allocated the


CPU for execution
New job Ready Running Job processing
completed

I/O Job must wait for I/O


completed completion

Blocked

Three different states of jobs in main memory in a multiprogramming system

Ref. Page 283 Chapter 14: Operating Systems Slide 16/81


Computer Fundamentals : Pradeep K. Sinha & Priti Sinha

Requirements of Multiprogramming Systems

 Large memory
 Memory protection
 Job status preservation
 Proper job mix (CPU and I/O bound jobs)
 CPU scheduling

Ref. Page 284 Chapter 14: Operating Systems Slide 17/81


Computer Fundamentals : Pradeep K. Sinha & Priti Sinha

Process Control Block (PCB)


process identifier

process state
program counter
values of various CPU
registers
accounting and
scheduling information
I/O status information

PCB is used to preserve the job status of each loaded


process in a multiprogramming system

Ref. Page 284 Chapter 14: Operating Systems Slide 18/81


Computer Fundamentals : Pradeep K. Sinha & Priti Sinha

Multitasking

 Multitasking is single-user variation of multiprogramming


concept
 Both refer to the same concept of a system’s capability to
work concurrently on more than one task
 Some authors prefer to use the term multiprogramming for
multi-user systems and multitasking for single-user systems
 Multitasking eases user operation and saves lots of time when
a user has to switch between two or more applications while
performing a job
 Multiprogramming is interleaved execution of multiple jobs in
a multi-user system, while multitasking is interleaved
execution of multiple jobs in a single-user system

Ref. Page 284 Chapter 14: Operating Systems Slide 19/81


Computer Fundamentals : Pradeep K. Sinha & Priti Sinha

Multithreading

 Threads are a popular way to improve application


performance
 In traditional operating systems, the basic unit of CPU
utilization is a process
 Each process has its own program counter, its own register
states, its own stack, and its own address space
 In operating systems with threads facility, the basic unit of
CPU utilization is a thread
 A process consists of an address space and one or more
threads of control

(Continued on next slide…)

Ref. Page 285 Chapter 14: Operating Systems Slide 20/81


Computer Fundamentals : Pradeep K. Sinha & Priti Sinha

Multithreading

 Each thread of a process has its own program counter, its


own register states, and its own stack
 All the threads of a process share the same address space
 All threads of a process also share the same set of operating
system resources
 Threads are often referred to as lightweight processes and
traditional processes are referred to as heavyweight
processes

Ref. Page 285 Chapter 14: Operating Systems Slide 21/81


Computer Fundamentals : Pradeep K. Sinha & Priti Sinha

Multithreading System

Address space Address space


Thread Thread Thread Thread

(a) (b)

(a) Single-threaded and (b) multithreaded processes. A single-


threaded process corresponds to a process of a traditional
operating system. [Reproduced with permission, from the
book titled Distributed Operating Systems: Concepts and
Design by Pradeep K. Sinha. © 1997 IEEE, USA].

Ref. Page 286 Chapter 14: Operating Systems Slide 22/81


Computer Fundamentals : Pradeep K. Sinha & Priti Sinha

Motivations for Using Threads

 Overhead involved in creating a new process is considerably


greater than that for creating a new thread within a process
 New thread uses the address space of its process
 Overhead involved in CPU switching among peer threads is
very small as compared to CPU switching among processes
 Resources are shared more efficiently among multiple threads
of a process than among multiple processes
 Users find the threads model more intuitive for application
programming

Ref. Page 285 Chapter 14: Operating Systems Slide 23/81


Computer Fundamentals : Pradeep K. Sinha & Priti Sinha

Multiprocessing
 System with two or more CPUs having ability to execute
multiple processes concurrently
 Multiple CPUs are used to process either instructions from
different and independent programs or different
instructions from the same program simultaneously
 Types of multiprocessing:
 Tightly-coupled: Single system-wide primary memory
shared by all processors
 Loosely-coupled: Each processor has its own local
memory

Ref. Page 286 Chapter 14: Operating Systems Slide 24/81


Computer Fundamentals : Pradeep K. Sinha & Priti Sinha
CPU, Memory, and I/O Processors of a
Computer System

Main
memory

I/O Units I/O


CPU
Processors

Ref. Page 287 Chapter 14: Operating Systems Slide 25/81


Computer Fundamentals : Pradeep K. Sinha & Priti Sinha

Multiprocessing System

CPU-1 Main memory CPU-2

I/O processors I/O processors

I/O units I/O units

Ref. Page 287 Chapter 14: Operating Systems Slide 26/81


Computer Fundamentals : Pradeep K. Sinha & Priti Sinha
Difference between Multiprogramming and
Multiprocessing

 Multiprocessing is simultaneous execution of two or more


processes by a computer system having more than one CPU
 Multiprogramming is interleaved execution of two or more
processes by a single-CPU system
 Multiprogramming involves execution of a portion of one
program, then a portion of another, etc., in brief consecutive
periods
 Multiprocessing involves simultaneous execution of several
program segments of the same or different programs

Ref. Page 287 Chapter 14: Operating Systems Slide 27/81


Computer Fundamentals : Pradeep K. Sinha & Priti Sinha

Time-sharing

 Simultaneous interactive use of a computer system by


many users in such a way that each one feels that
he/she is the sole user of the system
 Many user terminals are connected to the same
computer simultaneously
 Uses multiprogramming with a special CPU scheduling
algorithm
 Short period during which a user process gets to use
CPU is known as time slice, time slot, or quantum
 CPU is taken away from a running process when the
allotted time slice expires

Ref. Page 288 Chapter 14: Operating Systems Slide 28/81


Computer Fundamentals : Pradeep K. Sinha & Priti Sinha
Process State Diagram for a Time-Sharing
System

Job is allocated to
CPU for execution
New job Ready Running Job processing
completed
Allotted time slice is over

I/O Job must wait for


completed I/O completion

Blocked

Process state diagram for a time-sharing system

Ref. Page 288 Chapter 14: Operating Systems Slide 29/81


Computer Fundamentals : Pradeep K. Sinha & Priti Sinha

Requirements of Time-sharing Systems

 Time-sharing systems require following additional hardware


and software
 Number of user terminals
 Large memory to support multiprogramming
 Memory protection mechanism to prevent a job’s instructions and
data from other jobs
 Job status preservation mechanism to preserve a job’s status
information when the operating system takes away CPU from it,
and restores this information back
 Special CPU scheduling algorithm that allocates CPU for a short
period one-by-one to each user process
 Interrupt mechanism to send an interrupt signal to CPU after
every time slice

Ref. Page 289 Chapter 14: Operating Systems Slide 30/81


Computer Fundamentals : Pradeep K. Sinha & Priti Sinha

Advantages of Time-sharing Systems

 Reduces CPU idle time


 Provides advantages of quick response time
 Offers good computing facility to small users

Ref. Page 289 Chapter 14: Operating Systems Slide 31/81


Computer Fundamentals : Pradeep K. Sinha & Priti Sinha

Memory Management

Chapter 14: Operating Systems Slide 32/81


Computer Fundamentals : Pradeep K. Sinha & Priti Sinha

Memory Management

 Memory is important resource of a computer system


that must be properly managed for the overall system
performance
 Memory management module:
 Keeps track of parts of memory in use and parts not in use
 Allocates memory to processes as needed and deallocates
when no longer needed

Ref. Page 290 Chapter 14: Operating Systems Slide 33/81


Computer Fundamentals : Pradeep K. Sinha & Priti Sinha

Uniprogramming Memory Model

 Used in systems that process one job only at a time, and


all system resources are available exclusively for the job
until it completes
 Simple and easy to implement
 Does not lead to proper utilization of the main memory as
unoccupied memory space by the currently active user
process remains unused
 Used only on very small or dedicated computer systems

Ref. Page 290 Chapter 14: Operating Systems Slide 34/81


Computer Fundamentals : Pradeep K. Sinha & Priti Sinha

Uniprogramming Memory Model

Operating system area Operating system

User process
User area

Unused

Ref. Page 290 Chapter 14: Operating Systems Slide 35/81


Computer Fundamentals : Pradeep K. Sinha & Priti Sinha

Multiprogramming Memory Models

 In a multiprogramming system, multiple user processes


can reside simultaneously in main memory
 Two memory management schemes used to facilitate this
are:
 Multiprogramming with fixed number of memory partitions:
User area of the memory is divided into a number of fixed-
sized partitions
 Multiprogramming with variable number of memory
partitions: Number, size and location of the partitions vary
dynamically as processes come and go

Ref. Page 290 Chapter 14: Operating Systems Slide 36/81


Computer Fundamentals : Pradeep K. Sinha & Priti Sinha
Multiprogramming with Fixed Number of
Memory Partition

Operating system area Operating system

Partition 1

Partition 2
User area divided into n
equal-sized partitions Partition 3

Partition n

Ref. Page 291 Chapter 14: Operating Systems Slide 37/81


Computer Fundamentals : Pradeep K. Sinha & Priti Sinha
Multiprogramming with Fixed Number of
Memory Partition
Time (a), (b), …, (h)
Operating Operating Operating Operating
system system system system
P1 P1 P1
P1 P2 P3
comes comes comes
P2 P2
User
Free
area Free
P3
Free
Free

(a) (b) (c) (d)


The number, size, and location of the partitions vary dynamically as
processes come and go. (contd…)

Ref. Page 292 Chapter 14: Operating Systems Slide 38/81


Computer Fundamentals : Pradeep K. Sinha & Priti Sinha
Multiprogramming with Variable Number of
Memory Partitions

Operating Operating Operating Operating


system system system system
P5
P1 P1 Free 3
P4 Free 3
P2 P1 P5
P2
Comes which
P4 terminates P4 comes P4
terminates cannot fit in
Free 2 Free 1 so is which can
allocated fit in
space from Free 2 Free 3 Free 2
Free 2
Free 2

P3 P3 P3 P3

Free 1 Free 1 Free 1 Free 1

(e) (f) (g) (h)

The number, size, and location of the partitions vary dynamically as processes come and go.

Ref. Page 292 Chapter 14: Operating Systems Slide 39/81


Computer Fundamentals : Pradeep K. Sinha & Priti Sinha

Virtual Memory

 Conventional memory management schemes suffer from two


main limitations
 Operating system cannot load a process until sufficient free
memory for loading the entire process becomes available
 Operating system cannot load a process if main memory size is
less than the total memory required
 Virtual memory is a memory management scheme that
overcomes these limitations by allowing execution of a
process without the need to load the process in main memory
completely

Ref. Page 292 Chapter 14: Operating Systems Slide 40/81


Computer Fundamentals : Pradeep K. Sinha & Priti Sinha

How is Virtual Memory Realized?


 On-line secondary storage
 On-line secondary storage device having much larger capacity
than main memory
 Swapping
 Swapping is the process of transferring a block of data from on-
line secondary storage to main memory or vice-versa
 Demand paging
 Instead of loading an entire process before its execution can
start, the operating system uses a swapping algorithm
 When operating system needs to swap to continue a process’s
execution, it invokes a page-replacement algorithm to create one
for the accessed page
 Page replacement deals with selecting a page that is residing in
memory but is not in use currently
(Continued on next slide…)

Ref. Page 293 Chapter 14: Operating Systems Slide 41/81


Computer Fundamentals : Pradeep K. Sinha & Priti Sinha

How is Virtual Memory Realized?

 Virtual memory is often described as a hierarchy of two


storage systems – one is a low-cost, large-capacity, low-
speed system (on-line disk storage), and the other is a high-
cost, small-capacity, high-speed system (main memory)

Ref. Page 293 Chapter 14: Operating Systems Slide 42/81


Computer Fundamentals : Pradeep K. Sinha & Priti Sinha

Advantages of Virtual Memory


 Provides a large virtual memory to programmers on a
system having smaller physical memory
 Enables execution of a process on a system whose main
memory size is less than the total memory required by the
process
 Enables a process’s execution to be started even when
sufficient free memory for loading the entire process is not
available
 Makes programming easier as programmers no longer
need to worry about the memory size limitations
 Often leads to less I/O activity resulting in better
throughput, turnaround time, and response time

Ref. Page 293 Chapter 14: Operating Systems Slide 43/81


Computer Fundamentals : Pradeep K. Sinha & Priti Sinha

Disadvantages of Virtual Memory

 Difficult to implement because it requires algorithms to


support demand paging
 If used carelessly, it may substantially decrease
performance due to high page fault rate

Ref. Page 294 Chapter 14: Operating Systems Slide 44/81


Computer Fundamentals : Pradeep K. Sinha & Priti Sinha

File Management

Chapter 14: Operating Systems Slide 45/81


Computer Fundamentals : Pradeep K. Sinha & Priti Sinha

File Management

 A file is a collection of related information


 Every file has a name, its data and attributes
 File’s name uniquely identifies it in the system and is used
by its users to access it
 File’s data is its contents
 File’s attributes contain information such as date & time of
its creation, date & time of last access, date & time of last
update, its current size, its protection features, etc.
 File management module of an operating system takes
care of file-related activities such as structuring,
accessing, naming, sharing, and protection of files

Ref. Page 294 Chapter 14: Operating Systems Slide 46/81


Computer Fundamentals : Pradeep K. Sinha & Priti Sinha

File Access Methods

 Sequential access files


 Operating systems use sequential access files for storage of files
on sequential access storage media
 A process can read the bytes or records in the file in the order in
which they are stored
 Random access files
 Operating systems use random access files for storage of files on
random access storage media
 Applications can access the contents of a random access file
randomly, irrespective of the order in which the bytes or records
are stored

Ref. Page 294 Chapter 14: Operating Systems Slide 47/81


Computer Fundamentals : Pradeep K. Sinha & Priti Sinha

File Operations (Examples)


File operation Usage
Create Is used to create a new file.
Delete Is used to delete an existing file that is no longer needed.
Open Is used to open an existing file when a user wants to start using it.
Close Is used to close a file when the user has finished using it.
Read Is used to read data stored in a file.
Write Is used to write new data in a file.
Seek Is used with random access files to first position read/write pointer
to a specific place in file so that data can be read from, or written to,
that position.
Get attributes Is used to access the attributes of a file.
Set attributes Is used to change user-settable attributes (such as, protection
mode) of a file.
Rename Is used to change name of an existing file.
Copy Is used to create a copy of a file, or to copy a file to an I/O device,
such as a printer.

Ref. Page 295 Chapter 14: Operating Systems Slide 48/81


Computer Fundamentals : Pradeep K. Sinha & Priti Sinha

File Naming
File naming deals with the rules for naming files in an
operating system. This may include such rules as:
 Maximum number of characters that a file name may
have
 Special characters allowed in a file name
 Distinction between upper case and lower case letters
 Multi-part file names allow file extensions to be part of a
file name. File extensions indicate something about the
file and its content
 Used by applications to check for the intended type of
file before operating on it

Ref. Page 295 Chapter 14: Operating Systems Slide 49/81


Computer Fundamentals : Pradeep K. Sinha & Priti Sinha

File Extensions (Example)

File
Its meaning
extension
.bas Basic source program file
.c C source program file
.ftn Fortran source program file
.pas Pascal source program file
.obj Object file (compiler output, not yet linked)
.bin Executable binary program file
.lib Library of .obj files used by the linker
.dat Data file
.hlp Text file for HELP command
.man Online manual page file

(Continued on next slide…)

Ref. Page 296 Chapter 14: Operating Systems Slide 50/81


Computer Fundamentals : Pradeep K. Sinha & Priti Sinha

File Extensions (Example)

File
Its meaning
extension
.txt General text file
.bak Backup file
.doc Microsoft word document file
.wav Microsoft windows sound file
.wk4 Lotus 1-2-3 spreadsheet file
.xls Microsoft Excel spreadsheet file
.jpg JPEG graphics file
.gif GIF graphics file

Ref. Page 296 Chapter 14: Operating Systems Slide 51/81


Computer Fundamentals : Pradeep K. Sinha & Priti Sinha

Device Management

Chapter 14: Operating Systems Slide 52/81


Computer Fundamentals : Pradeep K. Sinha & Priti Sinha

Controlling I/O Devices

 Computer uses device controllers to connect I/O devices to it


 Each device controller is in charge of and controls a set of
devices of a specific type
 Device controller maintains some local buffer storage and is
responsible for moving data between an I/O device that it
controls and its local buffer storage
 Device controller also has a few registers that it uses for
communicating with CPU
 These registers are part of the regular memory address space
 This scheme is called memory-mapped I/O

(Continued on next slide…)

Ref. Page 297 Chapter 14: Operating Systems Slide 53/81


Computer Fundamentals : Pradeep K. Sinha & Priti Sinha

Controlling I/O Devices

 Two methods to transfer data from the controller’s local buffer


to the appropriate memory area of the computer are:
 Non-DMA transfer
 As soon as transfer of data from input device to the controller’s
local buffer is complete, the controller sends an interrupt signal to
CPU
 CPU then stops what it is doing currently, and transfers control of
execution to the starting address of the service routine, which
handles the interrupt
 Interrupt service routine transfers the data from local buffer of
the device controller to main memory

(Continued on next slide…)

Ref. Page 297 Chapter 14: Operating Systems Slide 54/81


Computer Fundamentals : Pradeep K. Sinha & Priti Sinha

Controlling I/O Devices

 DMA transfer
 When the operating system prepares for data transfer
operation, it writes the relevant commands and their associated
parameters into the controller’s registers
 After the controller has read the data from the device into its
buffer, it copies the data one byte or word at a time from its
buffer into main memory at the specified memory address
 It does not involve the CPU
 Device controller sends an interrupt to CPU only after it
completes copying the entire data

Ref. Page 297 Chapter 14: Operating Systems Slide 55/81


Computer Fundamentals : Pradeep K. Sinha & Priti Sinha
Simple and Easy User Interface to
I/O Devices

 Operating systems provide simple and easy user interface to


all I/O devices
 They achieve this by organizing the software for using I/O
devices as a series of layers
 Lower layers hide the internal details
 Upper layers present a nice, clean, uniform interface to the
users

(Continued on next slide…)

Ref. Page 298 Chapter 14: Operating Systems Slide 56/81


Computer Fundamentals : Pradeep K. Sinha & Priti Sinha

Layers of I/O System

Supports standard I/O system calls as library


User-level software procedures.
I/O software
layers Performs I/O functions that are common to all
Device-independent
devices and maps symbolic device names to the
software proper device driver.

Converts I/O requests into suitable commands


Device drivers for the appropriate device controller and writes
the relevant commands and their associated
parameters into the controller’s registers.

Causes interrupt to wakeup the device driver


Interrupt handlers
after it completes data transfer.

I/O hardware I/O devices hardware Performs actual data I/O.

Ref. Page 298 Chapter 14: Operating Systems Slide 57/81


Computer Fundamentals : Pradeep K. Sinha & Priti Sinha

Security

Chapter 14: Operating Systems Slide 58/81


Computer Fundamentals : Pradeep K. Sinha & Priti Sinha

Security

 Deals with protecting the various resources and information


of a computer system against destruction and unauthorized
access
 External security: Deals with securing computer against
external factors such as fires, floods, earthquakes, stolen
disks/tapes, etc. by maintaining adequate backup, using
security guards, allowing access to sensitive information to
only trusted employees/users, etc.
 Internal security: Deals with user authentication, access
control, and cryptography mechanisms

Ref. Page 298 Chapter 14: Operating Systems Slide 59/81


Computer Fundamentals : Pradeep K. Sinha & Priti Sinha

Security

 User authentication: Deals with the problem of


verifying the identity of a user (person or program)
before permitting access to the requested resource
 Access Control: Once authenticated, access control
mechanisms prohibit a user/process from accessing those
resources/information that he/she/it is not authorized to
access
 Cryptography: Means of encrypting private information
so that unauthorized access cannot use information

Ref. Page 298 Chapter 14: Operating Systems Slide 60/81


Computer Fundamentals : Pradeep K. Sinha & Priti Sinha

Command Interpretation

Chapter 14: Operating Systems Slide 61/81


Computer Fundamentals : Pradeep K. Sinha & Priti Sinha

Command Interpretation

 Provides a set of commands using which the user can give


instructions to the computer for getting some job done by
it
 Commands supported by the command interpretation
module are known as system calls

(Continued on next slide…)

Ref. Page 299 Chapter 14: Operating Systems Slide 62/81


Computer Fundamentals : Pradeep K. Sinha & Priti Sinha

Command Interpretation

Two types of user interfaces supported by various operating


systems are:
 Command-line interface: User gives instructions to
the computer by typing the commands
 Graphical User Interface (GUI): User gives
commands to the system by selecting icon or menu
item displayed on the screen with the use of a point-
and-draw device

Ref. Page 299 Chapter 14: Operating Systems Slide 63/81


Computer Fundamentals : Pradeep K. Sinha & Priti Sinha

OS Capability
Enhancement Software

Chapter 14: Operating Systems Slide 64/81


Computer Fundamentals : Pradeep K. Sinha & Priti Sinha

OS Capability Enhancement Software

 Perform several tasks of routine nature, frequently


needed by users but are not provided as part of the OS
 They are primarily grouped into three categories:
 Translating programs: Translate a source program
into an object program
 Library programs: Consist of frequently used
functions and operations
 Utility programs: Assist users with system
maintenance tasks such as disk formatting, data
compression, data backups, antivirus utilities

Ref. Page 300 Chapter 14: Operating Systems Slide 65/81


Computer Fundamentals : Pradeep K. Sinha & Priti Sinha

Some Popular
Operating Systems

Chapter 14: Operating Systems Slide 66/81


Computer Fundamentals : Pradeep K. Sinha & Priti Sinha

UNIX OS

 Developed in the early 1970s at Bell Laboratories by Ken


Thompson and Dennis Ritchie
 Written in C high-level language, hence, highly portable
 Multi-user, time-sharing OS
 Used on a wide variety of computers ranging from
notebook computers to super computers
 Especially prevalent on RISC workstations such as those
from Sun Microsystems, Hewlett-Packard, IBM, and
Silicon Graphics
 Structured in three layers – kernel, shell, and utilities

Ref. Page 302 Chapter 14: Operating Systems Slide 67/81


Computer Fundamentals : Pradeep K. Sinha & Priti Sinha

MS-DOS

 Stands for Microsoft Disk Operating System.


 Single-user OS for IBM and IBM-compatible personal
computers (PC)
 Structured in three layers – BIOS (Basic Input Output
System), kernel, and shell
 Very popular in the 1980s. Not in much use now after
development of Microsoft Windows OS in 1990s

Ref. Page 302 Chapter 14: Operating Systems Slide 68/81


Computer Fundamentals : Pradeep K. Sinha & Priti Sinha

Microsoft Windows

 Developed by Microsoft to overcome limitations of MS-


DOS operating system
 Single-user, multitasking OS
 Native interface is a GUI
 Designed to be not just an OS but also a complete
operating environment
 OS of choice for most PCs after 1990

Ref. Page 303 Chapter 14: Operating Systems Slide 69/81


Computer Fundamentals : Pradeep K. Sinha & Priti Sinha
Microsoft Windows Server
(Earlier Known as Windows NT)
 Multi-user, time-sharing OS developed by Microsoft
 Designed to have UNIX-like features so that it can be
used for powerful workstations, network, and database
servers
 Supports multiprogramming and is designed to take
advantage of multiprocessing on systems having
multiple processors
 Native interface is a GUI
 Built-in networking and communications features
 Provides strict system security
 Rich set of tools for software development
 Can run Microsoft Windows applications and many UNIX
applications directly

Ref. Page 304 Chapter 14: Operating Systems Slide 70/81


Computer Fundamentals : Pradeep K. Sinha & Priti Sinha

Linux
 Open-source OS enhanced and backed by thousands of
programmers world-wide
 Multi-tasking, multiprocessing OS, originally designed to
be used in PCs
 Name “Linux” is derived from its inventor Linus Torvalds
 Several Linux distributions available (Red Hat, SuSE).
Difference in distribution is mostly set of tools, number
and quality of applications, documentation, support, and
service

Ref. Page 304 Chapter 14: Operating Systems Slide 71/81


Computer Fundamentals : Pradeep K. Sinha & Priti Sinha

Mac OS

 Designed in mid 1980s by Apple Incorporation

 Main objective was ‘ease of use’

 First OS to introduce the idea of GUI (Graphical


User Interface), which was later adopted by
almost all Operating Systems

Ref. Page 305 Chapter 14: Operating Systems Slide 72/81


Computer Fundamentals : Pradeep K. Sinha & Priti Sinha

Key Features of Mac OS Include

 Intuitive user interface


 Interoperable with iOS and WatchOS
 Supported with a large set of built-in applications
 iCloud facility
 Privacy and security features help users work in a
trusted environment
 Flexibility to work with Windows OS
 Use by differently abled users

Ref. Page 305 Chapter 14: Operating Systems Slide 73/81


Computer Fundamentals : Pradeep K. Sinha & Priti Sinha

iOS

 Designed in 2007 by Apple Incorporation for its


mobile devices such as iPad, iPhone and iPod.

 Provides a protective shell for each application


(app) to prevent other apps from tampering them

 Two apps can communicate directly, if approved

Ref. Page 306 Chapter 14: Operating Systems Slide 74/81


Computer Fundamentals : Pradeep K. Sinha & Priti Sinha

Key Features of iOS Include


 Highly intuitive user interface
 Facility to write, mark and draw
 Facility to ask for information or instruct using voice
interface
 Interoperable with Mac OS and WatchOS
 Supported with a large set of applications and games
 iCloud facility
 Multitasking facility
 Camera, music and maps
 Privacy and security features help users work in a trusted
environment

Ref. Page 306 Chapter 14: Operating Systems Slide 75/81


Computer Fundamentals : Pradeep K. Sinha & Priti Sinha

WatchOS

 Designed in 2015 by Apple Incorporation for its smart wrist


watch (Apple Watch)

 It is based on iOS and has many similarities with iOS in


terms of features

Ref. Page 307 Chapter 14: Operating Systems Slide 76/81


Computer Fundamentals : Pradeep K. Sinha & Priti Sinha

Key Features of WatchOS Include

 Intuitive user interface

 Health Kit

 Music

 Contact list, calendar, with notifications for important dates,


appointment, etc., calculator and many other useful
applications

 Ability to share data with other Apple devices

Ref. Page 307 Chapter 14: Operating Systems Slide 77/81


Computer Fundamentals : Pradeep K. Sinha & Priti Sinha

Android OS
 An open source OS for mobile devices from Google

 Google developed it from Open Handset Alliance (OHA), a


business alliance of companies to develop open standard for
mobile devices

 It is Linux based, as it uses Linux kernel at its core for basic


system functionalities

 It has millions of applications, making it the most versatile


software environment for mobile devices

Ref. Page 308 Chapter 14: Operating Systems Slide 78/81


Computer Fundamentals : Pradeep K. Sinha & Priti Sinha

Key Features Android OS Include

 Intuitive user interface


 Lets users choose their hardware device
 Portable across current and future hardware platforms
 Its architecture is flexible because it is component based
 It supports all Google services (Gmail, Google search, etc.)
 It supports 2D and 3D graphics, video streaming, and
multilingual interface
 It supports multiple keyboards and makes them easy to
install
 It supports multi-layer security

Ref. Page 308 Chapter 14: Operating Systems Slide 79/81


Computer Fundamentals : Pradeep K. Sinha & Priti Sinha

Keywords/Phrases
 Access control  Lightweight processes
 Android OS  Linux
 Batch processing  Loosely coupled system
 Command interpretation  Mac OS
 Command-line interface (CLI)  Memory management
 CPU-bound jobs  Memory partition
 Cryptography  Microsoft Windows
 Demand paging  Microsoft Windows NT
 Device manageemnt  MS-DOS
 External security  Multiprocessing
 File  Multiprogramming
 File attributes  Multiprogramming with fixed tasks (MFT)
 File extensions  Multiprogramming with variable tasks (MVT)
 File management  Multitasking
 Graphical User Interface (GUI)  Multithreading
 I/O-bound jobs  Operating system
 iOS  Process
 Internal security  Process Control Block (PCB)
 Job  Process management
 Job control language (JCL)  Random access files
 Library programs  Response time (Continued on next slide…)

Chapter 14: Operating Systems Slide 80/81


Computer Fundamentals : Pradeep K. Sinha & Priti Sinha

Keywords/Phrases

 Security
 Sequential access files
 Swapping
 Throughput
 Tightly coupled system
 Time-sharing
 Time slice
 Time slot
 Translating programs
 Turnaround time
 Uniprogramming system
 Unix
 User authentication
 Utility programs
 Virtual machine
 Virtual memory
 WatchOS

Chapter 14: Operating Systems Slide 81/81


Computer Fundamentals : Pradeep K. Sinha & Priti Sinha

Computer Fundamentals

Pradeep K. Sinha
Priti Sinha

Chapter 15

Application
Software Packages
Chapter 15: Application Software Packages Slide 1/26
Computer Fundamentals : Pradeep K. Sinha & Priti Sinha

Learning Objectives

In this chapter you will learn about :

 Word-processing package
 Spreadsheet package
 Graphics package
 Personal assistance package

Chapter 15: Application Software Packages Slide 2/26


Computer Fundamentals : Pradeep K. Sinha & Priti Sinha

Word-Processing Package

Chapter 15: Application Software Packages Slide 3/26


Computer Fundamentals : Pradeep K. Sinha & Priti Sinha

Word-Processing Package

 Word-processing describes use of hardware and software


to create, edit, view, format, store, retrieve, and print
documents (written material such as letters, reports,
books, etc.)
 Word-processing package enables us to do all these on
a computer system

Ref. Page 314 Chapter 15: Application Software Packages Slide 4/26
Computer Fundamentals : Pradeep K. Sinha & Priti Sinha
Commonly Supported Features in a
Word-Processing Package

 Entering text  Printing documents


 Editing text  Importing text, graphics and
 Formatting page style images

 Formatting text  Searching and replacing text


string
 Entering mathematical
symbols  Checking spelling

 Displaying documents  Checking grammar and style

 Saving, retrieving and


deleting documents

Ref. Page 314 Chapter 15: Application Software Packages Slide 5/26
Computer Fundamentals : Pradeep K. Sinha & Priti Sinha

Word-Processing (Few Terminologies)

 Style sheet: Pre-stored page format that can be used


while creating a new document or can be applied to an
existing document
 Font: Complete set of characters with the same style
and size. A word-processing package comes with several
standard fonts
 Points: A point is 1/72 of an inch, and the size refers to
the distance from the top of the tallest character to the
bottom of the character that extends the lowest. Font
size is measured in points

(Continued on next slide)

Ref. Page 315 Chapter 15: Application Software Packages Slide 6/26
Computer Fundamentals : Pradeep K. Sinha & Priti Sinha

Word-Processing (Few Terminologies)

 Three commonly used font styles are italic, bold and


underline.
 Justification: Alignment of text on the left or the right
margin, or on both margins. Four types of justification
are:
 Left-justification
 Right-justification
 Center-justification
 Full-justification

Ref. Page 316 Chapter 15: Application Software Packages Slide 7/26
Computer Fundamentals : Pradeep K. Sinha & Priti Sinha

Different Font Types (Examples)

This sentence is written in Times New Roman font.

This sentence is written in Helvetica font.

This sentence is written in Palatino font.

This sentence is written in Courier New font.

This sentence is written in Antique Olive font.

Ref. Page 315 Chapter 15: Application Software Packages Slide 8/26
Computer Fundamentals : Pradeep K. Sinha & Priti Sinha

Different Font Sizes (Examples)

This sentence is written in 10 point Times New Roman font.

This sentence is written in 12 point Times New Roman font.

This sentence is written in 16 point Times New Roman font.

This sentence is written in 24 point Times New Roman font.

This sentence is written in 36 point Times


New Roman font.

Ref. Page 316 Chapter 15: Application Software Packages Slide 9/26
Computer Fundamentals : Pradeep K. Sinha & Priti Sinha

Different Font Styles (Examples)

This sentence is written in italic style.

This sentence is written in bold style.

This sentence is written in underline style.

You can even make individual words italic, bold,


or underline.

Ref. Page 316 Chapter 15: Application Software Packages Slide 10/26
Computer Fundamentals : Pradeep K. Sinha & Priti Sinha

Different Justification Styles (Examples)

The term hardware refers to the physical devices of a


computer system. Thus, the input, storage, processing,
control, and output devices are hardware.
(a) Left Justified text

The term hardware refers to the physical devices of a


computer system. Thus, the input, storage, processing,
control, and output devices are hardware.
(b) Right Justified text

The term hardware refers to the physical devices of a


computer system. Thus, the input, storage, processing,
control, and output devices are hardware.
(c) Centered text

Ref. Page 317 Chapter 15: Application Software Packages Slide 11/26
Computer Fundamentals : Pradeep K. Sinha & Priti Sinha

Mathematical Symbols (Examples)

 (2)   
t R t    u  Su    u1  u2
(u)

   

 a, b, c    a, b   a, b  r   a, c  s 

Ref. Page 319 Chapter 15: Application Software Packages Slide 12/26
Computer Fundamentals : Pradeep K. Sinha & Priti Sinha

Spreadsheet Package

Chapter 15: Application Software Packages Slide 13/26


Computer Fundamentals : Pradeep K. Sinha & Priti Sinha

Spreadsheet Package

 Spreadsheet package is a numeric data analysis tool


that allows us to create a computerized ledger
 Useful for any numerical analysis problem whose data
can be organized as rows and columns

Ref. Page 321 Chapter 15: Application Software Packages Slide 14/26
Computer Fundamentals : Pradeep K. Sinha & Priti Sinha

Few Uses of Spreadsheet Package

 Maintaining and analyzing inventory, payroll, and other


accounting records by accountants
 Preparing budgets and bid comparisons by business analysts
 Recording grades of students and carrying out various types
of analysis of the grades by educators
 Analyzing experimental results by scientists and researchers
 Tracking stocks and keeping records of investor accounts by
stockbrokers
 Creating and tracking personal budgets, loan payments, etc.
by individuals

Ref. Page 321 Chapter 15: Application Software Packages Slide 15/26
Computer Fundamentals : Pradeep K. Sinha & Priti Sinha
Common Features of Spreadsheet
Package

 Support for a large number of cells


 Support for addressing a range of cells by the addresses of
the endpoint cells
 Support for different types of cell data (such as label,
numeric value, formula, and date & time)
 Support for use of relative and absolute cell addresses in
formula
 Support for a wide range of commands
 Support for displaying numeric data in the form of graphs
and charts

Ref. Page 322 Chapter 15: Application Software Packages Slide 16/26
Computer Fundamentals : Pradeep K. Sinha & Priti Sinha

Sample Spreadsheet
A label running across
Row numbers
multiple columns
Column
letters A B C D E F
1 FINAL EXAM MARKS SHEET(CLASS-X: 2020)
2
3 NAME PHYS CHEM MATHS TOTAL PERCENT A label
4 Cell F4
5 P. Davis 92 95 88 275 91.66

6 A. Raje 86 82 94 262 87.33


7 D. Rana 75 83 85 243 81.00
8 M. Ray 77 75 72 224 74.66
9 J. Smith 94 92 96 282 94.00
10
11
Result of the
Alphabetic Value Numeric Cell C11 Result of the function formula
in a Cell Value in a @SUM(B9..D9) + E9/3
Cell

Ref. Page 322 Chapter 15: Application Software Packages Slide 17/26
Computer Fundamentals : Pradeep K. Sinha & Priti Sinha
Examples of a Line Graph, a Bar Chart
and a Pie Chart

10%

40%

35%

15%
(a) A line graph (b) A bar chart (c) A pie chart

Ref. Page 325 Chapter 15: Application Software Packages Slide 18/26
Computer Fundamentals : Pradeep K. Sinha & Priti Sinha

Graphics Package

Chapter 15: Application Software Packages Slide 19/26


Computer Fundamentals : Pradeep K. Sinha & Priti Sinha

Graphics Package

Graphics package enables us to use a computer system


for creating, editing, viewing, storing, retrieving and
printing designs, drawings, pictures, graphs and anything
else that can be drawn in the traditional manner

Ref. Page 325 Chapter 15: Application Software Packages Slide 20/26
Computer Fundamentals : Pradeep K. Sinha & Priti Sinha

Common Features of Graphics Package

 Drawing designs
 Painting drawings and pictures
 Presenting graphs and charts
 Dragging-and-dropping graphic objects
 Importing graphic objects
 Capturing screen snapshots

Ref. Page 325 Chapter 15: Application Software Packages Slide 21/26
Computer Fundamentals : Pradeep K. Sinha & Priti Sinha

Computer Graphics (Few Terminologies)

 Computer-aided-design (CAD): Integration of


computers and graphics design packages for the purpose
of automating the design and drafting process
 Vector graphics: Graphic object composed of patterns of
lines, points, circles, arcs and other geometric shapes
that can be easily represented by few geometric
parameters
 Raster graphics: Graphic object composed of patterns of
dots called pixels

Ref. Page 325 Chapter 15: Application Software Packages Slide 22/26
Computer Fundamentals : Pradeep K. Sinha & Priti Sinha

Personal Assistance
Package

Chapter 15: Application Software Packages Slide 23/26


Computer Fundamentals : Pradeep K. Sinha & Priti Sinha

Personal-assistance Package

Personal-assistance package allows individuals to:


 Use personal computers for storing and retrieving their
personal information
 Planning and managing their schedules, contacts,
finances and inventory of important items

Ref. Page 327 Chapter 15: Application Software Packages Slide 24/26
Computer Fundamentals : Pradeep K. Sinha & Priti Sinha
Common Features of Personal
Assistance Package

 Calendar
 To-do list
 Address book
 Investments book
 Inventory book

Ref. Page 327 Chapter 15: Application Software Packages Slide 25/26
Computer Fundamentals : Pradeep K. Sinha & Priti Sinha

Key Words/Phrases
 Bit-mapped image  Style sheet
 Bold  Underline
 Cell  Vector graphics
 Center justification  What You See Is What you Get
 Clip-art library (WYSIWYG)
 Computer Aided Design (CAD)  Word-processing
 Font  Word-processing package
 Full justification
 Graphics package
 Italic
 Justification
 Landscape mode
 Left justification
 Personal assistance package
 Portrait mode
 Raster graphics
 Right justification
 Spreadsheet package

Chapter 15: Application Software Packages Slide 26/26


Computer Fundamentals: Pradeep K. Sinha & Priti Sinha

Computer Fundamentals

Pradeep K. Sinha
Priti Sinha

Chapter 16

Business Data
Processing
Chapter 16: Business Data Processing Slide 1/52
Computer Fundamentals: Pradeep K. Sinha & Priti Sinha

Learning Objectives

In this chapter you will learn about:


 Difference between data and information
 Data storage hierarchy commonly used to facilitate data
processing
 Standard methods of organizing data
 File Management System (FMS)
 Database Management System (DBMS)
 Basic concepts and main components of FMS and DBMS

Chapter 16: Business Data Processing Slide 2/52


Computer Fundamentals: Pradeep K. Sinha & Priti Sinha

Basic Concepts

Chapter 16: Business Data Processing Slide 3/52


Computer Fundamentals: Pradeep K. Sinha & Priti Sinha

Data Processing

 Data is a collection of facts – unorganized but able to


be organized into useful information
 Information is data arranged in an order and form that
is useful to the people who receive it
 Data processing is a series of actions or operations
that converts data into useful information
 A data processing system includes resources such as
people, procedures, and devices used to process input
data for producing desirable output

Ref. Page 330 Chapter 16: Business Data Processing Slide 4/52
Computer Fundamentals: Pradeep K. Sinha & Priti Sinha

Data Storage Hierarchy

A single binary digit (0 or 1).


Level 0 Bit

Level 1 Character Multiple related bits are combined to form a character (byte).

Level 2 Field Multiple related characters are combined to form a field.

Level 3 Record Multiple related fields are combined to form a record.

Level 4 File Multiple related records are combined to form a file.

Level 5 Multiple related files are integrated to form a


Database
database.

Ref. Page 331 Chapter 16: Business Data Processing Slide 5/52
Computer Fundamentals: Pradeep K. Sinha & Priti Sinha
Relationship Among
Character, Field, Record, and File

A field having Employee Code First Name Last Name Hours worked Hourly rate Tax rate
4 characters 0004 Kumar Rana 40 14.00 0.09

Employee Code First Name Last Name Hours worked Hourly rate Tax rate
0003 Pratap Singh 43 15.00 0.10
Employee Code First Name Last Name Hours worked Hourly rate Tax rate
0002 Ravi Patel 42 10.00 0.07

Employee Code First Name Last Name Hours worked Hourly rate Tax rate
0001 Pradeep Sinha 45 12.00 0.08
A record

Records
Fields of a file

Ref. Page 332 Chapter 16: Business Data Processing Slide 6/52
Computer Fundamentals: Pradeep K. Sinha & Priti Sinha

Standard Methods of
Organizing Data

Chapter 16: Business Data Processing Slide 7/52


Computer Fundamentals: Pradeep K. Sinha & Priti Sinha

File-oriented Approach

 Application’s data is organized into one or more files and the


application program(s) processes the data stored in these
files to generate desired output
 It is customary to use a master file of permanent data, and
transaction files containing data of temporary nature

Ref. Page 333 Chapter 16: Business Data Processing Slide 8/52
Computer Fundamentals: Pradeep K. Sinha & Priti Sinha

Limitations of File-oriented Approach

 Limited query flexibility


 When the key field is not relevant to desired information, it
needs to search entire file
 Data redundancy
 Repetition of same data items in more than one file is
known as data redundancy
 It leads to increase in cost of data entry and data storage
 Data integrity problem
 Data integrity refers to consistency of data in all files
 Any change in a data item must be carried out in every file
containing that field

Ref. Page 333 Chapter 16: Business Data Processing Slide 9/52
Computer Fundamentals: Pradeep K. Sinha & Priti Sinha

Limitations of File-oriented Approach

 Lack of program/data independence


 An application program usually contains data format
statements, which define the format of each data field precisely
as the application needs it for processing
 Data dependence occurs when data is dependent on application
 Limited data security flexibility
 Offers file-level data security feature
 It can enforce data access restrictions on an entire file only, not
on a record or a field of data item

Ref. Page 333 Chapter 16: Business Data Processing Slide 10/52
Computer Fundamentals: Pradeep K. Sinha & Priti Sinha

Database-oriented Approach
 This approach integrates together data from multiple related
files in the form of a database having following properties:
 Provides greater query flexibility
 Reduces data redundancy
 Solves data integrity (inconsistency) problem
 Makes data independent of application programs
 Includes data security features at database level, record level,
and even at field level

Ref. Page 333 Chapter 16: Business Data Processing Slide 11/52
Computer Fundamentals: Pradeep K. Sinha & Priti Sinha

File Management System

Chapter 16: Business Data Processing Slide 12/52


Computer Fundamentals: Pradeep K. Sinha & Priti Sinha

What is File Management System?

 File-oriented approach of organizing data provides a set


of programs to facilitate users to organize, create, delete,
update, and manipulate their files
 All these programs together form a File Management
System (FMS)

Ref. Page 334 Chapter 16: Business Data Processing Slide 13/52
Computer Fundamentals: Pradeep K. Sinha & Priti Sinha

File Types

A file management system supports following file types:


 Transaction file: Stores input data until it can be
processed
 Master file: Contains all current data relevant to an
application
 Output file: Stores output produced by one program
that is used as input to another program
 Report file: Holds a copy of a report generated by an
application
 Backup file: Copy of a file, created as a safety
precaution against loss of data

Ref. Page 334 Chapter 16: Business Data Processing Slide 14/52
Computer Fundamentals: Pradeep K. Sinha & Priti Sinha

File Organization

 Deals with physical organization of records of a file for


convenience of their storage and retrieval
 Selection of a particular file organization depends on
application type
 File organization requires use of some key field in every
record in a file
 Key field value must be unique for each record of the file

Ref. Page 335 Chapter 16: Business Data Processing Slide 15/52
Computer Fundamentals: Pradeep K. Sinha & Priti Sinha

Sequential Files
 A sequential file stores its records one after another in
ascending/descending order of their key field values
 A computer processes a sequential file in the order in which
the file stores its records
 Sequential file organization is the most efficient and
economical file organization for applications in which we have
to update a large number of file records at regularly
scheduled intervals
 Activity ratio is ratio of total number of records in transaction
file and total number of records in master file

(Continued on next slide…)

Ref. Page 335 Chapter 16: Business Data Processing Slide 16/52
Computer Fundamentals: Pradeep K. Sinha & Priti Sinha

Sequential Files
 Advantages
 Simple to understand and use
 Easy to organize and maintain
 Need relatively inexpensive I/O media and devices
 Efficient and economical to use for applications in which activity
ratio is high
 Disadvantages
 Inefficient and uneconomical to use for applications in which
activity ratio is low
 Limited to batch-processing environment because of the need to
accumulate transactions in batches
 Precludes possibility of up-to-the-minute data because of the need
to accumulate transactions in batches
 Requires extra overhead of sorting the files before using them for
processing
 Leads to data redundancy problem

Ref. Page 335 Chapter 16: Business Data Processing Slide 17/52
Computer Fundamentals: Pradeep K. Sinha & Priti Sinha

Direct Files
 Direct/random file organization is suitable for applications that
directly locate any record by its key field value, without having to
search through a sequence of other records
 A direct file stores each record at a location to which the address-
generating function maps the record’s key field value
 This mechanism is known as hashing and the address-generating
function is called hashing algorithm
 Hashing algorithm sometimes maps the key values of two or more
records to same storage address. This problem is known as collision
 To search a record, given its key value, the computer applies the
hashing algorithm on the given key to generate its corresponding
address
 If required, an application can process the records of a direct file
sequentially in ascending/descending sequence of key field value
(Continued on next slide…)

Ref. Page 336 Chapter 16: Business Data Processing Slide 18/52
Computer Fundamentals: Pradeep K. Sinha & Priti Sinha

Direct Files
 Advantages
 Can quickly locate and retrieve any record directly
 Does not require sorting of transactions
 Does not require accumulation of transactions in batches
 Can support interactive online applications
 Application can process direct file records sequentially

 Disadvantages
 Require relatively expensive hardware and software resources
 Due to address generation overhead involved, they are less
efficient and economical than sequential files for high activity ratio
applications
 Often require special security and access synchronization
mechanisms

Ref. Page 337 Chapter 16: Business Data Processing Slide 19/52
Computer Fundamentals: Pradeep K. Sinha & Priti Sinha

Indexed Sequential Files


 In indexed sequential file organization, there are two files for
every data file – data file and index file
 Data file can store the records in random sequence
 Index file stores the index keys in sorted sequence on index
key value
 This technique of file management is known as Indexed
Sequential Access Method (ISAM) and files of this type are
called ISAM files

(Continued on next slide…)

Ref. Page 337 Chapter 16: Business Data Processing Slide 20/52
Computer Fundamentals: Pradeep K. Sinha & Priti Sinha

Indexed Sequential File: Example

Employee Address
Address location Employee record
code (key) location
0001 1003 1001 0002 R. S. Patel …
0002 1001 1002 0004 R. K. Rana …
0003 1004 1003 0001 K. P. Sinha …
0004 1002 1004 0003 N. P. Singh …

Index file Data file

Ref. Page 338 Chapter 16: Business Data Processing Slide 21/52
Computer Fundamentals: Pradeep K. Sinha & Priti Sinha

Indexed Sequential Files

 Advantages
 Applications in which activity ratio is high, can use index sequential
files quite efficiently for sequential processing
 Applications in which activity ratio is low, can also use index
sequential files quite efficiently for direct access processing

 Disadvantages
 Require relatively expensive hardware and software resources
 Require more storage space than other types of files
 Are unsuitable for online applications requiring direct access to
records

Ref. Page 338 Chapter 16: Business Data Processing Slide 22/52
Computer Fundamentals: Pradeep K. Sinha & Priti Sinha

File Utilities
 Are routines, which perform generic operations on data files
 Sorting utility
 Arranges records of a file in some defined sequence
 Keys determine the sorting sequence of the file’s records
 Enables users to specify their sequencing requirements for a
file by means of input parameters
 Reads un-sequenced records of an input file, and by means of
various copying techniques, ultimately produces an output file
containing records of the input file in desired sequence
 Searching utility
 Finds a particular record in a file
 Matches the specified key values with their values in each
record to search the desired record
 Efficiency of a search algorithm depends on file organization
(Continued on next slide…)

Ref. Page 338 Chapter 16: Business Data Processing Slide 23/52
Computer Fundamentals: Pradeep K. Sinha & Priti Sinha

File Utilities
 Searching a record from a direct or index sequential file
requires much less time than searching a record from a
sequential file
 Merging utility
 Combines records of two or more ordered (sorted) files into a
single ordered file
 Requires records of each of the input files to be sorted in the
same order, although their record layout need not be identical
 Places records from each of the input files in their correct
relative order, producing an output file having all records in the
same order as input files
 Copying utility
 Produces a copy of a file either from one unit of a storage
device to another similar unit or from one storage medium to
another (Continued on next slide…)

Ref. Page 340 Chapter 16: Business Data Processing Slide 24/52
Computer Fundamentals: Pradeep K. Sinha & Priti Sinha

File Utilities

 Users often use file copying utility to take back-up copies of


files
 Copying utilities are also known as peripheral interchange
programs (PIP) since users often use them to copy a file from
one peripheral device to another
 Printing utility
 Printing utility prints a file on a printer to produce hard copy of
its contents
 Provides the facility to print file contents in different formats
 Provides some selection and editing facilities to enable printing
of parts of files
 Provides special formats for printing files that contain program
instructions rather than data

(Continued on next slide…)

Ref. Page 340 Chapter 16: Business Data Processing Slide 25/52
Computer Fundamentals: Pradeep K. Sinha & Priti Sinha

File Utilities

 Maintenance utility
 Copies data from one or more files to a new file selectively, or
updates a file’s contents selectively

Ref. Page 341 Chapter 16: Business Data Processing Slide 26/52
Computer Fundamentals: Pradeep K. Sinha & Priti Sinha

Sorting on One Key and Two Keys: Examples

Other fields Other fields


(Name, Employee Department (Name, Address,
Employee Department Address, code code Qualification, Basic
code code Qualification, salary, etc.)
Basic salary,
etc.) 124 1 ---
101 2 --- 178 1 ---
123 3 --- 213 1 ---
124 1 --- 101 2 ---
176 2 ---
176 2 ---
178 1 ---
123 3 ---
202 3 ---
202 3 ---
213 1 ---

Sorting on one key in ascending Sorting on two keys in ascending employee-code (secondary
employee-code sequence key) within ascending department-code (primary key)

Ref. Page 339 Chapter 16: Business Data Processing Slide 27/52
Computer Fundamentals: Pradeep K. Sinha & Priti Sinha

Merging Utility: Example

Input file Output file Input file


Employee Other Employee Other Employee Other
code fields code fields code fields
125 … 112 … 112 …
127 … 119 … 119 …
137 … 125 … 129 …
146 … 127 … 139
159 … 129 … 150 …
137 152 …
File A
139 …
File B
146 …
150 …
152 …
159 …
File C
Merging of files A and B to produce file C

Ref. Page 340 Chapter 16: Business Data Processing Slide 28/52
Computer Fundamentals: Pradeep K. Sinha & Priti Sinha

Database Management
System

Chapter 16: Business Data Processing Slide 29/52


Computer Fundamentals: Pradeep K. Sinha & Priti Sinha

Database Management System

 In database-oriented approach of organizing data, a


set of programs is provided to facilitate users in
organizing, creating, deleting, updating, and
manipulating data in a database
 All these programs together form a Database
Management System (DBMS)

Ref. Page 341 Chapter 16: Business Data Processing Slide 30/52
Computer Fundamentals: Pradeep K. Sinha & Priti Sinha

Database Models

 Database model defines the manner in which the


various files of a database are linked together.
 Four commonly used database models are:
 Hierarchical
 Network
 Relational
 Object-oriented

Ref. Page 341 Chapter 16: Business Data Processing Slide 31/52
Computer Fundamentals: Pradeep K. Sinha & Priti Sinha

Hierarchical Databases
 Hierarchical database links its data elements as an inverted
tree structure
 Below the single-root data element are subordinate elements,
each of which, in turn, has its own subordinate elements, and
so on
 Tree can grow to multiple levels
 There may be many children elements under each parent
element, but there can be only one parent element for any
child element
 Main limitation of hierarchical database is that it does not
support flexible data access
 Applications can access its data elements only by following
paths formed by branches of the tree structure

Ref. Page 341 Chapter 16: Business Data Processing Slide 32/52
Computer Fundamentals: Pradeep K. Sinha & Priti Sinha

Hierarchical Database: Example

Organization A parent element

Personnel Finance Technical


department department department

Managers Support Managers Support Managers Engineers Technicians Support


staff staff staff

A child element

Ref. Page 341 Chapter 16: Business Data Processing Slide 33/52
Computer Fundamentals: Pradeep K. Sinha & Priti Sinha

Network Databases

 Network database is an extension of hierarchical database


 Organizes its data elements in such a manner that they
have parent-child relationship among them
 Designer must determine all types of relationships among
data elements while designing the database
 A child data element can have more than one parent
element or no parent element at all
 Parent and child elements can have many-to-many
relationships

Ref. Page 342 Chapter 16: Business Data Processing Slide 34/52
Computer Fundamentals: Pradeep K. Sinha & Priti Sinha

Network Database: Example

College

Computer
Courses English Hindi Mathematics
Science

Students Seeta Geeta Ram Mohan Sohan Raju

A child element can have more than one parent element


This child element has no parent element

Ref. Page 342 Chapter 16: Business Data Processing Slide 35/52
Computer Fundamentals: Pradeep K. Sinha & Priti Sinha

Relational Databases

 Relational database organizes its data elements as multiple


tables with rows and columns
 Each table column represents a data field, and each row
represents a data record (also known as a tuple)
 Relational database model provides greater flexibility of data
organization and future enhancements in database as
compared to hierarchical and network database models
 Applications can organize their data elements in a relational
database in a manner that is identical to real-life relationships
between data elements

(Continued on next slide…)

Ref. Page 343 Chapter 16: Business Data Processing Slide 36/52
Computer Fundamentals: Pradeep K. Sinha & Priti Sinha

Relational Databases

 For adding new data to an existing relational database, there


is no need to redesign the database afresh
 Users can also reorganize data elements, when necessary, to
create new tables by selecting certain rows or specific
columns from other tables, or by joining columns and rows
from two separate tables

Ref. Page 343 Chapter 16: Business Data Processing Slide 37/52
Computer Fundamentals: Pradeep K. Sinha & Priti Sinha

Relational Database: Example


Membership Member’s Member’s Address Borrower Book No. Due Date
No. name (Membership No.) (ISBN) (DD-MM-YYYY)

83569 K. N. Raina C-15, Sarita Vihar, Pune-7 12859 27-21675-2 10-12-2020


62853 D. P. Singh A-22, Anand Park, Pune-5 11348 89303-530-0 08-11-2020
12859 R. Pandey D-18, Vrindavan, Pune-7 32228 13-201702-5 10-11-2020
32228 R. S. Gupta A-12, Nandanvan, Pune-2 16185 22-68111-7 05-12-2020
23466 S. K. Ray B-05, Royal Villa, Pune-3 12859 71606-214-0 06-11-2020
11348 P. K. Sen B-16, Anand Park, Pune-5 62853 13-48049-8 15-11-2020
16185 T. N. Murli A-11, Vrindavan, Pune-7 11348 18-23614-1 12-11-2020
(a) Members data table. (b) Borrowed books data table

Book No. (ISBN) Book Title Author


13-201702-5 Concepts of Physics H. C. Verma
13-48049-8 Concepts of Chemistry S. S. Dubey
18-23614-1 Astrology for You N. K. Sharma
(c) Books data table
22-68111-7 Fundamentals of Computers K. Ramesh
27-21675-2 C++ Programming R. P. Rajan
71606-214-0 Computer Networks A. N. Rai
89303-530-0 Database Systems P. N. Dixit

Ref. Page 343 Chapter 16: Business Data Processing Slide 38/52
Computer Fundamentals: Pradeep K. Sinha & Priti Sinha

Sample Report

List of overdue books as on 10-11-2020


Membership Member’s Member’s Due Book No. Book Title Book
No. Name Address Date Author
11348 P. K. Sen B-16, 08-11 89303-530-0 Database P. N. Dixit
Anand Park, Systems
Pune-5
32228 R. S. Gupta A-12, 10-11 13-201702-5 Concepts of H. C. Verma
Nandanvan, Physics
Pune-2
12859 R. Pandey D-18, 06-11 71606-214-0 Computer A. N. Rai
Vrindavan, Networks
Pune-7

A report of overdue books as of 10-11-2020 from the


sample database of previous slide

Ref. Page 344 Chapter 16: Business Data Processing Slide 39/52
Computer Fundamentals: Pradeep K. Sinha & Priti Sinha

Object-oriented Databases

 Some key features that several applications require for


effective modeling are:
 Ability to model complex nested entities
 Support for general data types found in object-oriented
programming languages
 Support for frequently useful object-oriented concepts such as
object, class, inheritance, etc.
 Support for proper match between object-oriented programming
languages and database languages
 Object-oriented database is a collection of objects whose
behavior, state, and relationships are in accordance with
object-oriented concepts

(Continued on next slide…)

Ref. Page 344 Chapter 16: Business Data Processing Slide 40/52
Computer Fundamentals: Pradeep K. Sinha & Priti Sinha

Object-oriented Databases

 Object-oriented database management system allows


definition and manipulation of an object-oriented database
 It provides direct support for the definition and
manipulation of the relationships among objects

Ref. Page 344 Chapter 16: Business Data Processing Slide 41/52
Computer Fundamentals: Pradeep K. Sinha & Priti Sinha

Object-Oriented Database
Vehicle VehicleSpecs

Id Length
Color Width
Specifications Height
Manufacturer Engine Type
Fuel Type
Fuel Tank Capacity
No. of Wheels
TwoWheeler FourWheeler
Other details Other details
of the vehicle of the vehicle Company Employee
like with/ like no. of
without gear, doors, seating Name Id
seating capacity, etc. Location Name
capacity, etc. President Age

DomesticCompany ForeignCompany

Class/subclass link Other details of Other details of


Attribute/domain link the company the company

Ref. Page 345 Chapter 16: Business Data Processing Slide 42/52
Computer Fundamentals: Pradeep K. Sinha & Priti Sinha

Main Components of a DBMS

 DBMS allows users to organize, process and retrieve


selected data from a database without knowing about the
underlying database structure
 Four major components of a DBMS that enable this are:
 Data Definition Language (DDL): Used to define the
structure (schema) of a database
 Data Manipulation Language (DML): Provides
commands to enable the users to enter and manipulate
the data

(Continued on next slide)

Ref. Page 346 Chapter 16: Business Data Processing Slide 43/52
Computer Fundamentals: Pradeep K. Sinha & Priti Sinha

Main Components of a DBMS

 Query Language: Enables users to define their


requirements for extracting the desired information
from the database in the form of queries
 Report generator: Enables the users of a database
to design the layout of a report so that it can be
presented in the desired format

Ref. Page 347 Chapter 16: Business Data Processing Slide 44/52
Computer Fundamentals: Pradeep K. Sinha & Priti Sinha

Creating a Database

Creation of a database is a three step process:


 Defining its structure (schema)
 Designing forms (custom screens) for displaying and
entering data
 Entering the data into it

Ref. Page 348 Chapter 16: Business Data Processing Slide 45/52
Computer Fundamentals: Pradeep K. Sinha & Priti Sinha

Sample Database Form


EMPLOYEE DATABASE DATA ENTRY FORM

EMPLOYEE ID: 856392 SEX: M AGE: 42

EMPLOYEE NAME: LAST NAME: SINHA

FIRST NAME: PRADEEP

MIDDLE NAME: KUMAR

CONTACT ADDRESS: ADDRESS 1: F/8, ANAND PARK

ADDRESS 2: SOCIETY, AUNDH

CITY: PUNE

STATE: MH
POSTAL CODE: 411007

TELEPHONE NO.: (020) 5680-489

ANY OTHER INFORMATION: IS FLUENT IN JAPANESE LANGUAGE

Ref. Page 349 Chapter 16: Business Data Processing Slide 46/52
Computer Fundamentals: Pradeep K. Sinha & Priti Sinha
Viewing, Modifying, Deleting, and
Adding Records

 All database systems provide commands to view,


modify, delete, or add records of an already established
database
 Many database systems also provide a facility to set up
a filter allowing user to browse through and view only
those records that meet some criterion

Ref. Page 350 Chapter 16: Business Data Processing Slide 47/52
Computer Fundamentals: Pradeep K. Sinha & Priti Sinha

Searching a Database

Commonly supported features for enabling a user to


search for desired information in a database are:

 Find command: Used for simple database queries


 Query language: Used for more complex database
queries
 Query By Example (QBE): Provides a simple user
interface for specifying search criteria

Ref. Page 351 Chapter 16: Business Data Processing Slide 48/52
Computer Fundamentals: Pradeep K. Sinha & Priti Sinha

Creating Reports

 Reports are generated by using report generator of a


database system to assemble the output of a database
query in desired format
 Report generator enables a user to specify layout of the
report, titles & subtitles for the report, column
headings for various fields, and other elements to
make the report appear more presentable

Ref. Page 352 Chapter 16: Business Data Processing Slide 49/52
Computer Fundamentals: Pradeep K. Sinha & Priti Sinha

Sample Output of Report

LIST OF EMPLOYEES WHO BELONG TO PUNE


DATE: DECEMBER 17, 2020

LAST FIRST ADDRESS-1 ADDRESS-2 TELEPHONE


NAME NAME NUMBER
Gupta Rajiv A-12, Nandanvan M. G. Road 4623-4892
Murli Tapan A-11, Vrindavan Pashan Road 5863-4905
Pandey Rupa D-18, Vrindana Pashan Road 5865-3236
Raina Pushpa C-15, Sarita Vihar Aundh Road 5755-8328
Ray Suhas B-05, Royal Villa M. G. Road 4685-6356

Sen Prakash B-16, Anand Park Aundh Road 5762-3333


Singh Deepak A-22, Anand Park Aundh Road 5728-6287

The report is sorted in alphabetical order on last name of employee

Ref. Page 353 Chapter 16: Business Data Processing Slide 50/52
Computer Fundamentals: Pradeep K. Sinha & Priti Sinha

Key Words/Phrases

 Activity ratio  Database model


 Backup file  Direct file
 Collision  Field
 Copying  File
 Data  File Management System (FMS)
 Data Definition Language (DDL)  File utilities
 Data dependence  Filter
 Data dictionary  Hashing
 Data file  Hashing algorithm
 Data integrity  Hierarchical database
 Data Manipulation Language  Index file
(DML)  Indexed sequential file
 Data processing  Information
 Data redundancy  Master file
 Data storage hierarchy  Merging
 Database  Network database
 Database administrator  Output file
 Database Management System  Peripheral Interchange Program
(DBMS)  Primary key

(Continued on next slide)

Chapter 16: Business Data Processing Slide 51/52


Computer Fundamentals: Pradeep K. Sinha & Priti Sinha

Key Words/Phrases

 Query By Example
 Query language
 Record
 Relational database
 Report file
 Report Generator
 Schema
 Searching
 Secondary key
 Sequential file
 Sorting
 Transaction file
 Tuple

Chapter 16: Business Data Processing Slide 52/52


Computer Fundamentals : Pradeep K. Sinha & Priti Sinha

Computer Fundamentals

Pradeep K. Sinha
Priti Sinha

Chapter 17

Data Communications
& Computer Networks
Chapter 17: Data Communications & Computer Networks Slide 1/81
Computer Fundamentals : Pradeep K. Sinha & Priti Sinha

Learning Objectives
In this chapter you will learn about:
 Basic elements of a communication system
 Techniques, channels, and devices used to transmit data
between distant locations
 Types of computer networks
 Communication protocols and their use in computer
networks
 Internetworking tools and their use in building large
computer networks
 Wireless communications technologies and wireless
networks
 Characteristics and advantages of distributed computing
systems

Chapter 17: Data Communications & Computer Networks Slide 2/81


Computer Fundamentals : Pradeep K. Sinha & Priti Sinha

Basic Concepts and


Terminologies

Chapter 17: Data Communications & Computer Networks Slide 3/81


Computer Fundamentals : Pradeep K. Sinha & Priti Sinha
Data Communications and
Computer Networks

 A computer network is a network of computers


 It connects multiple computers in a manner to enable
meaningful transmission and exchange of data among them

Ref. Page 357 Chapter 17: Data Communications & Computer Networks Slide 4/81
Computer Fundamentals : Pradeep K. Sinha & Priti Sinha
Basic Elements of a Communication
System

 Communication is the process of transferring a message


from one point to another
 Electronic systems that transfer data from one point to
another are called data communication systems

Sender Medium Receiver


(source) Carries the (sink)
message
Creates and sends a Receives the message
message

Ref. Page 358 Chapter 17: Data Communications & Computer Networks Slide 5/81
Computer Fundamentals : Pradeep K. Sinha & Priti Sinha

Data Transmission Modes

Sender Receiver
(a) Simplex

Sender Receiver
OR
(or Receiver) (or Sender)
(b) Half-duplex

Sender Receiver
(and Receiver) AND (and Sender)
(c) Full-duplex

Ref. Page 358 Chapter 17: Data Communications & Computer Networks Slide 6/81
Computer Fundamentals : Pradeep K. Sinha & Priti Sinha

Data Transmission Speed

 Bandwidth: Range of frequencies available for data


transmission. It refers to data transmission rate. Higher
the bandwidth, the more data it can transmit
 Baud: Unit of measurement of data transfer rate.
Measured in bits per second (bps)

Ref. Page 359 Chapter 17: Data Communications & Computer Networks Slide 7/81
Computer Fundamentals : Pradeep K. Sinha & Priti Sinha

Data Transmission Speed Category

 Narrowband: Sub-voice grade channels in range from


45 to 300 baud. Mainly used for telegraph lines and
low-speed terminals
 Voiceband: Voice grade channels with speed up to
9600 baud. Mainly used for ordinary telephone voice
communication and slow I/O devices
 Broadband: High speed channels with speed up to 1
million baud or more. Mainly used for high-speed
computer-to-computer communication or for
simultaneous transmission of data

Ref. Page 359 Chapter 17: Data Communications & Computer Networks Slide 8/81
Computer Fundamentals : Pradeep K. Sinha & Priti Sinha

Data Transmission Media

Chapter 17: Data Communications & Computer Networks Slide 9/81


Computer Fundamentals : Pradeep K. Sinha & Priti Sinha

Data Transmission Media

The most commonly used ones are:

 Twisted-pair wire (UTP cable)


 Coaxial cable
 Microwave system
 Communications satellite
 Optical fibers

Ref. Page 360 Chapter 17: Data Communications & Computer Networks Slide 10/81
Computer Fundamentals : Pradeep K. Sinha & Priti Sinha

Unshielded Twisted-Pair (UTP) Cable

Ref. Page 360 Chapter 17: Data Communications & Computer Networks Slide 11/81
Computer Fundamentals : Pradeep K. Sinha & Priti Sinha

Coaxial Cable

Central copper
PVC insulation wire

Copper mesh

Outer PVC shield

Ref. Page 360 Chapter 17: Data Communications & Computer Networks Slide 12/81
Computer Fundamentals : Pradeep K. Sinha & Priti Sinha

Microwave Communication System

Transmitting antennas Receiving antennas


Transmitting station

In between
repeaters

Line of sight Line of sight Line of sight

Ref. Page 360 Chapter 17: Data Communications & Computer Networks Slide 13/81
Computer Fundamentals : Pradeep K. Sinha & Priti Sinha

Satellite Communication System

Satellite in space

6 GHz 4 GHz

Uplink Downlink

Transmitting Receiving
station on earth station on earth

Ref. Page 361 Chapter 17: Data Communications & Computer Networks Slide 14/81
Computer Fundamentals : Pradeep K. Sinha & Priti Sinha

Optical Fiber Communication System

Electrical Optical fiber Electrical


signal Electrical-to-light- Light-to-electrical- signal
wave converter wave converter
Amplifier
Sender Receiver
Light waves

Ref. Page 363 Chapter 17: Data Communications & Computer Networks Slide 15/81
Computer Fundamentals : Pradeep K. Sinha & Priti Sinha

Digital and Analog


Data Transmission

Chapter 17: Data Communications & Computer Networks Slide 16/81


Computer Fundamentals : Pradeep K. Sinha & Priti Sinha

Digital and Analog Data Transmission

 Analog signal: Transmitted power varies over a


continuous range. Example: sound, light, and radio
waves
 Digital signal: Sequence of voltage pulses represented
in binary form
 Computer generated data signal is digital, whereas
telephone lines carry analog signals

(Continued on next slide)

Ref. Page 364 Chapter 17: Data Communications & Computer Networks Slide 17/81
Computer Fundamentals : Pradeep K. Sinha & Priti Sinha

Digital and Analog Data Transmission

 When digital data is to be sent over an analog facility,


digital signals must be converted to analog form
 Conversion of digital signal to analog form is known as
modulation
 Conversion of analog signal to digital form is known as
demodulation
 Digital transmission of data is preferred over analog
transmission of data due to lower cost, higher
transmission speeds, and lower error rate

Ref. Page 364 Chapter 17: Data Communications & Computer Networks Slide 18/81
Computer Fundamentals : Pradeep K. Sinha & Priti Sinha

Analog and Digital Signals

Voltage
+v

t
0 1/f 2/f
-v
(a) Analog signal

v
1 1 1 1
0 0 0 0
t
(b) Digital signal

Ref. Page 365 Chapter 17: Data Communications & Computer Networks Slide 19/81
Computer Fundamentals : Pradeep K. Sinha & Priti Sinha

Modulation Techniques

 Amplitude Modulation (AM): Two binary values (0 and


1) of digital data are represented by two different
amplitudes of the carrier signal, keeping frequency and
phase constant
 Frequency Modulation (FM): Two binary values of
digital data are represented by two different frequencies,
while amplitude and phase are kept constant
 Phase Modulation (PM): Two binary values of digital
data are represented by shift in phase of carrier signal

Ref. Page 365 Chapter 17: Data Communications & Computer Networks Slide 20/81
Computer Fundamentals : Pradeep K. Sinha & Priti Sinha

Modems

 Modem is short for MOdulator/DEModulator


 Special device used for conversion of digital data to
analog form (modulation) and vice-versa (demodulation)
 Essential piece of hardware where two digital devices
(say two computers) want to communicate over an
analog transmission channel (say a telephone line)

Ref. Page 365 Chapter 17: Data Communications & Computer Networks Slide 21/81
Computer Fundamentals : Pradeep K. Sinha & Priti Sinha

Use of Modems in Data Communications

Analog signals on
Digital signals telephone line Digital signals

01 10 0 1 10
Modulator Demodulator
Sender Receiver
computer computer
Demodulator Modulator
0 10 0 0 1 0 0

A modem at A modem at receiver


sender computer computer end
end

Ref. Page 366 Chapter 17: Data Communications & Computer Networks Slide 22/81
Computer Fundamentals : Pradeep K. Sinha & Priti Sinha

Factors for Modem Selection

 Transmission speed
 Internal versus external
 Facsimile facility
 Error correction
 Data compression

Ref. Page 366 Chapter 17: Data Communications & Computer Networks Slide 23/81
Computer Fundamentals : Pradeep K. Sinha & Priti Sinha

Data Transmission
Services

Chapter 17: Data Communications & Computer Networks Slide 24/81


Computer Fundamentals : Pradeep K. Sinha & Priti Sinha

Data Transmission Services


 Data transmission service providers are popularly
known as common carriers
 Various types of services offered by common carriers
are:
 Dial-up line: Operates in a manner similar to a
telephone line
 Leased line: Special conditioned telephone line
that directly and permanently connects two
computers
 Integrated Services Digital Network (ISDN):
Telephone system that provides digital (not analog)
telephone and data services

(Continued on next slide)

Ref. Page 367 Chapter 17: Data Communications & Computer Networks Slide 25/81
Computer Fundamentals : Pradeep K. Sinha & Priti Sinha

Data Transmission Services

 Value Added Network (VAN): Provides value-added


data transmission service. Value added over and above
the standard services of common carriers may include
e-mail, data encryption/decryption, access to
commercial databases, and code conversion for
communication between computers

Ref. Page 368 Chapter 17: Data Communications & Computer Networks Slide 26/81
Computer Fundamentals : Pradeep K. Sinha & Priti Sinha

Multiplexing Techniques

Chapter 17: Data Communications & Computer Networks Slide 27/81


Computer Fundamentals : Pradeep K. Sinha & Priti Sinha

Multiplexing
 Method of dividing physical channel into many logical
channels so that a number of independent signals may
be simultaneously transmitted
 Electronic device that performs multiplexing is known
as a multiplexer
 Multiplexing enables a single transmission medium to
concurrently transmit data between several
transmitters and receivers

Ref. Page 368 Chapter 17: Data Communications & Computer Networks Slide 28/81
Computer Fundamentals : Pradeep K. Sinha & Priti Sinha

A Multiplexed System
T1 T2 T3 T4

Multiplexer

Modem

Modem

Multiplexer

Computer

Ref. Page 368 Chapter 17: Data Communications & Computer Networks Slide 29/81
Computer Fundamentals : Pradeep K. Sinha & Priti Sinha

Two Basic Methods of Multiplexing

 Frequency-Division Multiplexing (FDM): Available


bandwidth of a physical medium is divided into several
smaller, disjoint logical bandwidths. Each component
bandwidth is used as a separate communication line
 Time-Division Multiplexing (TDM): Total time
available in a channel is divided among several users,
and each user of the channel is allotted a time slice
during which he/she may transmit a message

Ref. Page 369 Chapter 17: Data Communications & Computer Networks Slide 30/81
Computer Fundamentals : Pradeep K. Sinha & Priti Sinha

Frequency-Division Multiplexing

Modulator Demodulator
Signal-1 40 KHz 40 KHz Signal-1

Sender end Receiver end


Signal-2 50 KHz 50 KHz Signal-2

Signal-3 60 KHz Channel 60 KHz Signal-3

Signal-4 70 KHz 70 KHz Signal-4

Signal-5 80 KHz 80 KHz Signal-5

Ref. Page 369 Chapter 17: Data Communications & Computer Networks Slide 31/81
Computer Fundamentals : Pradeep K. Sinha & Priti Sinha

Time-Division Multiplexing

Time sliced Reassembled


signals signals

Signal A A3 A2 A1 A3 A2 A1
Sender Receiver
end end
Signal B B3 B2 B1 Channel Demulti- B3 B2 B1
plexer

… C2 B2 A21 C1 B1 A1
Signal C C3 C2 C1 C3 C2 C1

Ref. Page 369 Chapter 17: Data Communications & Computer Networks Slide 32/81
Computer Fundamentals : Pradeep K. Sinha & Priti Sinha

Asynchronous and
Synchronous Transmission

Chapter 17: Data Communications & Computer Networks Slide 33/81


Computer Fundamentals : Pradeep K. Sinha & Priti Sinha
Asynchronous and Synchronous
Transmission

 Two modes of data transmission on a communication


line are asynchronous and synchronous
 Asynchronous transmission
 Sender can send data at any convenient time and
the receiver will accept it
 Data is transmitted character by character at
irregular intervals
 Well suited to many keyboard type terminals

(Continued on next slide)

Ref. Page 370 Chapter 17: Data Communications & Computer Networks Slide 34/81
Computer Fundamentals : Pradeep K. Sinha & Priti Sinha
Asynchronous and Synchronous
Transmission

 Synchronous transmission
 Sender and receiver must synchronize with each
other to get ready for data transmission before it
takes place
 Entire blocks of characters are framed and
transmitted together
 Well suited to remote communication between a
computer and such devices as buffered terminals
and printers

Ref. Page 371 Chapter 17: Data Communications & Computer Networks Slide 35/81
Computer Fundamentals : Pradeep K. Sinha & Priti Sinha

Asynchronous Transmission

Irregular time intervals Each character framed by


between two characters start and stop bits

Character Character Character

Ref. Page 370 Chapter 17: Data Communications & Computer Networks Slide 36/81
Computer Fundamentals : Pradeep K. Sinha & Priti Sinha

Synchronous Transmission

Indefinite time interval A block of characters may consist


between two blocks of data of hundreds of characters

Char Char Char Char Char Char

Trailer containing Header containing


end of block indication synchronizing and other
information

Ref. Page 370 Chapter 17: Data Communications & Computer Networks Slide 37/81
Computer Fundamentals : Pradeep K. Sinha & Priti Sinha

Switching & Routing


Techniques

Chapter 17: Data Communications & Computer Networks Slide 38/81


Computer Fundamentals : Pradeep K. Sinha & Priti Sinha

Switching Techniques
 Data is often transmitted from source to destination
through a network of intermediate nodes
 Switching techniques deal with the methods of
establishing communication links between the sender
and receiver in a communication network
 Three commonly used switching techniques are:
 Circuit switching: Dedicated physical path is
established between sending and receiving stations
through nodes of the network for the duration of
communication

(Continued on next slide)

Ref. Page 371 Chapter 17: Data Communications & Computer Networks Slide 39/81
Computer Fundamentals : Pradeep K. Sinha & Priti Sinha

Switching Techniques

 Message switching: Sender appends receiver’s


destination address to the message and it is
transmitted from source to destination either by
store-and-forward method or broadcast method
 Packet switching: Message is split up into fixed size
packets and each packet is transmitted independently
from source to destination node. Either store-and-
forward or broadcast method is used for transmitting
the packets. All the packets of a message are re-
assembled into original message at the destination
node

Ref. Page 372 Chapter 17: Data Communications & Computer Networks Slide 40/81
Computer Fundamentals : Pradeep K. Sinha & Priti Sinha

Circuit Switching Method

Switching nodes
Dotted lines and shaded
balls indicate the circuit
established

Source node Destination


node

Ref. Page 372 Chapter 17: Data Communications & Computer Networks Slide 41/81
Computer Fundamentals : Pradeep K. Sinha & Priti Sinha
Store-and-Forward Method of
Message Switching

4 B
A 1
3

Either path 1-2-3-4 or 1-5-4 may be used to


transmit a message from A to B.

Ref. Page 373 Chapter 17: Data Communications & Computer Networks Slide 42/81
Computer Fundamentals : Pradeep K. Sinha & Priti Sinha

Broadcast Method of Message Switching

Nodes 1 2 3 n

Message

Broadcast channel

Ref. Page 373 Chapter 17: Data Communications & Computer Networks Slide 43/81
Computer Fundamentals : Pradeep K. Sinha & Priti Sinha

Routing Techniques

 In a WAN, when multiple paths exist between the source


and destination nodes of a packet, any one of the paths
may be used to transfer the packet
 Selection of path to be used for transmitting a packet is
determined by the routing technique used

(Continued on next slide)

Ref. Page 374 Chapter 17: Data Communications & Computer Networks Slide 44/81
Computer Fundamentals : Pradeep K. Sinha & Priti Sinha

Routing Techniques

 Three popularly used routing algorithms are:


 Source routing: Source node selects the entire path
before sending the packet
 Hop-by-hop routing: Each node along the path
decides only the next node for the path
 Hybrid routing: Source node specifies only a few
major intermediate nodes of the complete path, and
hop-by-hop routing method is used to decide the
subpaths between any two of the specified nodes.

Ref. Page 374 Chapter 17: Data Communications & Computer Networks Slide 45/81
Computer Fundamentals : Pradeep K. Sinha & Priti Sinha

Network Topologies
and Types

Chapter 17: Data Communications & Computer Networks Slide 46/81


Computer Fundamentals : Pradeep K. Sinha & Priti Sinha

Network Topology
 A network’s topology refers to the way in which the network
links its nodes
 It determines the various data paths available between any
pair of nodes in the network
 Choice of a topology depends on a combination of factors
such as:
 Desired performance
 Desired reliability
 Size of the system
 Expandability
 Cost of components and services
 Availability of communication lines
 Acceptable delays in routing

Ref. Page 375 Chapter 17: Data Communications & Computer Networks Slide 47/81
Computer Fundamentals : Pradeep K. Sinha & Priti Sinha

Network Topologies
 Although number network topologies are possible, four
major ones are:
 Star network
 Ring network
 Completely connected network
 Multi-access bus network

Ref. Page 375 Chapter 17: Data Communications & Computer Networks Slide 48/81
Computer Fundamentals : Pradeep K. Sinha & Priti Sinha

Star Network

Host node

Ref. Page 375 Chapter 17: Data Communications & Computer Networks Slide 49/81
Computer Fundamentals : Pradeep K. Sinha & Priti Sinha

Ring Network

Ref. Page 376 Chapter 17: Data Communications & Computer Networks Slide 50/81
Computer Fundamentals : Pradeep K. Sinha & Priti Sinha

Completely Connected Network

Ref. Page 376 Chapter 17: Data Communications & Computer Networks Slide 51/81
Computer Fundamentals : Pradeep K. Sinha & Priti Sinha

Multi-Access Bus Network


Computers (nodes)

Single communication line shared by all nodes

Ref. Page 377 Chapter 17: Data Communications & Computer Networks Slide 52/81
Computer Fundamentals : Pradeep K. Sinha & Priti Sinha

Hybrid Network

Ring Star Completely connected

Ref. Page 377 Chapter 17: Data Communications & Computer Networks Slide 53/81
Computer Fundamentals : Pradeep K. Sinha & Priti Sinha

Network Types
 Five types of networks in common use are:
 Personal-area networks (PANs)
 Local-area networks (LANs)
 Campus-area networks (CANs)
 Metropolitan-area networks (MANs)
 Wide-area networks (WANs)

Ref. Page 378 Chapter 17: Data Communications & Computer Networks Slide 54/81
Computer Fundamentals : Pradeep K. Sinha & Priti Sinha

Communication Protocols

Chapter 17: Data Communications & Computer Networks Slide 55/81


Computer Fundamentals : Pradeep K. Sinha & Priti Sinha

Communication Protocols

 A protocol is a set of formal operating rules, procedures, or


conventions that govern a given process
 Communication or network protocol, therefore, describes
rules that govern transmission of data over communication
networks

Ref. Page 379 Chapter 17: Data Communications & Computer Networks Slide 56/81
Computer Fundamentals : Pradeep K. Sinha & Priti Sinha

Roles of a Communication Protocol

 Data sequencing
 Breaking a long message into smaller packets of fixed size
 Rules define method of numbering packets to detect loss or
duplication of packets, and to identify packets
 Data routing
 Decide the path between source and destination
 Data formatting
 Define which group of bits or characters within a packet
constitutes data, control, addressing, or other information
 Flow control
 Prevent a fast sender from flooding a slow receiver with data by
regulating flow of data on communication lines
(Continued on next slide)

Ref. Page 379 Chapter 17: Data Communications & Computer Networks Slide 57/81
Computer Fundamentals : Pradeep K. Sinha & Priti Sinha

Roles of a Communication Protocol


 Error control
 Detect errors in messages to ensure transmission of correct
messages
 Precedence and order of transmission
 Ensure that all nodes get a chance to use communication lines
and other resources
 Connection establishment and termination
 How connections are established, maintained, and terminated
 Data security
 Mechanisms for providing security and privacy of messages
sent/received
 Log information
 What types of log information the system should maintain for all
jobs and data communications tasks

Ref. Page 379 Chapter 17: Data Communications & Computer Networks Slide 58/81
Computer Fundamentals : Pradeep K. Sinha & Priti Sinha
Concept of Layered Protocols in
Network Design
 Networks have modular design for easy and efficient handling of
the system
 Consist of several modules, which are grouped into layers
logically
 Each layer offers certain services to higher layers, shielding those
layers from implementation details of services offered by lower
layers
 Each layer has its own set of protocols
 Main reasons for using layered protocols are:
 Layers makes their implementation more manageable
 Provides well-defined interfaces between layers
 Allows interaction between functionally paired layers in different
locations
 Protocol suite, protocol family, or protocol stack are terms used to
refer to a collection of protocols of a network system

Ref. Page 380 Chapter 17: Data Communications & Computer Networks Slide 59/81
Computer Fundamentals : Pradeep K. Sinha & Priti Sinha

Network Interface Card (NIC)

 Network Interface Card (NIC or network card) is a hardware


device that connects a computer to a network, both
functionally and physically
 It is an add-on card that is connected directly to a computer’s
I/O bus
 NIC’s ROM has the network’s physical-layer communication
protocol

Ref. Page 380 Chapter 17: Data Communications & Computer Networks Slide 60/81
Computer Fundamentals : Pradeep K. Sinha & Priti Sinha

The OSI Model

 The Open System Interconnection (OSI) model is


framework for defining standards for linking
heterogeneous computers in a packet switched network
 Standardized OSI protocol makes it possible for any two
heterogeneous computer systems, located anywhere in
the world, to easily communicate with each other
 Separate set of protocols is defined for each layer in its
seven-layer architecture. Each layer has an independent
function

Ref. Page 380 Chapter 17: Data Communications & Computer Networks Slide 61/81
Computer Fundamentals : Pradeep K. Sinha & Priti Sinha
Layers, Interfaces, and Protocols
in the OSI Model
Node 1 Node 2

Process A Process B

Application protocol
Layer 7 (application) Layer 7 (application)
Interface Interface
Presentation protocol Layer 6 (presentation)
Layer 6 (presentation)

Interface Interface
Session protocol
Layer 5 (session) Layer 5 (session)
Interface Interface
Transport protocol
Layer 4 (transport) Layer 4 (transport)
Interface Interface
Network protocol
Layer 3 (network) Layer 3 (network)

Interface Interface
Data-link protocol
Layer 2 (data link) Layer 2 (data link)
Interface Interface
Physical protocol
Layer 1 (physical) Layer 1 (physical)

Network

Ref. Page 381 Chapter 17: Data Communications & Computer Networks Slide 62/81
Computer Fundamentals : Pradeep K. Sinha & Priti Sinha
An example illustrating transfer of message M from sending node to the
receiving node in the OSI model: Hn, header added by layer n:Tn, trailer
added by layer n.

Sender node Receiver node

Process A Process B

H7 M H7 M

H6 H7 M H6 H7 M

H5 H6 H7 M H5 H6 H7 M

H4 H5 H6 H7 M1 H4 H5 H6 H7 M2 H4 H5 H6 H7 M1 H4 H5 H6 H7 M2

H3 H4 H5 H6 H7 M1 H3 H4 H5 H6 H7 M2 H3 H4 H5 H6 H7 M1 H3 H4 H5 H6 H7 M2

H2 H3 H4 H5 H6 H7 M1 T2 H2 H3 H4 H5 H6 H7 M2 T2 H2 H3 H4 H5 H6 H7 M1 T2 H2 H3 H4 H5 H6 H7 M2 T2

Ref. Page 384 Chapter 17: Data Communications & Computer Networks Slide 63/81
Computer Fundamentals : Pradeep K. Sinha & Priti Sinha

Internetworking Tools

Chapter 17: Data Communications & Computer Networks Slide 64/81


Computer Fundamentals : Pradeep K. Sinha & Priti Sinha

Internetworking

 Interconnecting two or more networks to form a single


network is called internetworking, and the resulting
network is called an internetwork
 Goal of internetworking is to hide details of different
physical networks, so that resulting internetwork
functions as a single coordinated unit
 Tools such as bridges, routers, brouters, and gateways
are used for internetworking
 The Internet is the best example of an internetwork

Ref. Page 384 Chapter 17: Data Communications & Computer Networks Slide 65/81
Computer Fundamentals : Pradeep K. Sinha & Priti Sinha

Bridges

 Operate at bottom two layers of the OSI model


 Connect networks that use the same communication
protocols above data-link layer but may use different
protocols at physical and data-link layers

Ref. Page 384 Chapter 17: Data Communications & Computer Networks Slide 66/81
Computer Fundamentals : Pradeep K. Sinha & Priti Sinha

Routers

 Operates at network layer of the OSI model


 Used to interconnect those networks that use the same
high-level protocols above network layer
 Smarter than bridges as they not only copy data from
one network segment to another, but also choose the
best route for the data by using routing table

Ref. Page 385 Chapter 17: Data Communications & Computer Networks Slide 67/81
Computer Fundamentals : Pradeep K. Sinha & Priti Sinha

Gateways

 Operates at the top three layers of the OSI model


(session, presentation and application)
 Used for interconnecting dissimilar networks that use
different communication protocols
 Since gateways interconnect dissimilar networks,
protocol conversion is the major job performed by
them

Ref. Page 385 Chapter 17: Data Communications & Computer Networks Slide 68/81
Computer Fundamentals : Pradeep K. Sinha & Priti Sinha

Wireless Networks

Chapter 17: Data Communications & Computer Networks Slide 69/81


Computer Fundamentals : Pradeep K. Sinha & Priti Sinha

Wireless Computing Systems

 A wireless computing system uses wireless


communication technologies for interconnecting computer
systems
 It enhances functionality of computing equipment by
freeing communication from location constraints of wired
computing systems
 Wireless computing systems are of two types:
 Fixed wireless systems: Support little or no
mobility of the computing equipment associated with
the wireless network
 Mobile wireless systems: Support mobility of the
computing equipment to access resources associated
with the wireless network

Ref. Page 385 Chapter 17: Data Communications & Computer Networks Slide 70/81
Computer Fundamentals : Pradeep K. Sinha & Priti Sinha

Issues in Wireless Computing Systems

 Lower bandwidth
 Variable bandwidth
 Higher error rate
 Increased security concern
 Dynamically changing network
 Lost or degraded connection
 Support for routing and location
management functions
 Limited power

Ref. Page 385 Chapter 17: Data Communications & Computer Networks Slide 71/81
Computer Fundamentals : Pradeep K. Sinha & Priti Sinha

Wireless Applications

 Interesting and important applications include:


 Mobile e-commerce applications (m-commerce)
 Web surfing
 Access to corporate data by employees while they are
traveling
 Mobile video-on-demand
 Location-sensitive services such as finding nearby movie
theaters or restaurants

Ref. Page 386 Chapter 17: Data Communications & Computer Networks Slide 72/81
Computer Fundamentals : Pradeep K. Sinha & Priti Sinha

Wireless Technologies

 1G, 2G, 3G, 4G and 5G


 Wireless LAN
 WiMAX (Worldwide Interoperability for
Microwave Access)
 Wireless Local Loop (WLL)
 Radio-router
 Multihop Wireless Network
 Wireless Application Protocol (WAP)

Ref. Page 387 Chapter 17: Data Communications & Computer Networks Slide 73/81
Computer Fundamentals : Pradeep K. Sinha & Priti Sinha

Mobile Wireless Communication Technologies

 The era of mobile wireless communication started in


1980.

 The five generations of mobile wireless communication


technologies since then are 1G, 2G, 3G, 4G and 5G.

 Every new generation made mobile wireless


communication faster than before and had improved or
new features than earlier generation technologies

Ref. Page 387 Chapter 17: Data Communications & Computer Networks Slide 74/81
Computer Fundamentals : Pradeep K. Sinha & Priti Sinha

S. No. Features 1G 2G 3G 4G 5G

1. Year of launch 1980 1991 2000 2010 2020 (expected)

Maximum 64 Kbps,
2.4
2. communication 384 Kbps 2 Mbps 1 Gbps 35.46 Gbps
Kbps
speed with 2.5G

3. Technology Analog Digital, CDMA LTE, WWWW,


GSM, 2000, MIMO, Massive MIMO,
CDMA UMTS, OFDM Millimeter Wave Mobile
EDGE Communications

Ref. Page 389 Chapter 17: Data Communications & Computer Networks Slide 75/81
Computer Fundamentals : Pradeep K. Sinha & Priti Sinha

S. No. Features 1G 2G 3G 4G 5G
4. Key Services Analog Digital Digital phone IP-based IP-based services
phone phone calls, True services including phone calls,
calls calls, and multimedia including Multimedia messaging,
Messaging messaging phone calls, Web access, HDTV,
(SMS, including Multimedia Video conferencing,
MMS) video, Video messaging, High-end mobile
conferencing, Web access, gaming, Mobile cloud
Mobile TV, HDTV, Video computing, Interactive
Video games, conferencing, multimedia
Web-based IP telephony, applications, Mobile
applications High-end applications based on
mobile device-to-device
gaming, communication (IoT
Mobile cloud applications), etc. with
computing far better experience
than before.

Ref. Page 389 Chapter 17: Data Communications & Computer Networks Slide 76/81
Computer Fundamentals : Pradeep K. Sinha & Priti Sinha

Distributed Computing
Systems

Chapter 17: Data Communications & Computer Networks Slide 77/81


Computer Fundamentals : Pradeep K. Sinha & Priti Sinha

Distributed Computing Systems


 It is a configuration, which consists of many independent
computer systems interconnected by a communication
network
 It enables sharing of many hardware and software resources,
as well as information, among several users who may be far
away from each other
 It is more complex to build because its design must:
 Enable it to use and manage a very large number of distributed
resources effectively
 Enable various nodes of the system to communicate with each
other reliably
 Include special security mechanisms to protect distributed
shared resources and services against intentional or accidental
security violations

Ref. Page 390 Chapter 17: Data Communications & Computer Networks Slide 78/81
Computer Fundamentals : Pradeep K. Sinha & Priti Sinha
Main Advantages of Distributed
Computing Systems
 Inherently distributed applications
 Information sharing among distributed users
 Resource sharing
 Better price-performance ratio
 Shorter response times and higher throughput
 Higher reliability
 Extensibility and incremental growth
 Better flexibility in meeting users’ needs

Ref. Page 390 Chapter 17: Data Communications & Computer Networks Slide 79/81
Computer Fundamentals : Pradeep K. Sinha & Priti Sinha

Keywords/Phrases
 1G technology  Completely connected network
 2G technology  Computer network
 3G technology  Data-link layer
 4G technology  Demodulation
 5G technology  Dial-up line
 Amplifier  Distributed Computing System
 Amplitude Modulation (AM)  Ethernet
 Application layer  Fax modem
 ARPANET  File Transfer Protocol (FTP)
 Asynchronous transmission  Frequency Modulation (FM)
 Bandwidth  Frequency-Division Multiplexing (FDM)
 Baud  Full duplex
 Bridge  Gateway
 Broadband  Half duplex
 Broadcast  Hop-by-hop routing
 Campus Area Network (CAN)  Hybrid network
 C-band transmission  Internet Protocol (IP)
 Circuit switching  Internetworking
 Coaxial cable  ISDN (Integrated Services Digital Network)
 Common Carriers  Ku-band transmission
 Communication protocol  Leased line
 Communications satellite  Local Area Network (LAN)
(Continued on next slide)

Chapter 17: Data Communications & Computer Networks Slide 80/81


Computer Fundamentals : Pradeep K. Sinha & Priti Sinha

Keywords/Phrases
 Message switching  Ring network
 Metropolitan Area Network (MAN)  Router
 Microwave system  Session layer
 Mobile computing  Simplex
 Modem  Source routing
 Modulation  Star network
 Multi-access Bus network  Store-and-forward
 Multiplexer  Synchronous transmission
 Narrowband  Time-Division Multiplexing (TDM)
 Network Interface Card (NIC)  Transport Control Protocol (TCP)
 Network layer  Transport layer
 Network topology  Twisted-pair
 Nomadic computing  Unshielded twisted-pair (UTP)
 Optical fibers  User Datagram Protocol (UDP)
 OSI Model  Value Added Network (VAN)
 Packet switching  Voiceband
 Phase Modulation (PM)  VSAT (Very Small Aperture Terminals)
 Physical layer  Wireless Application Protocol (WAP)
 POTS (Plain Old Telephone Service)  Wide Area Network (WAN)
 Presentation layer  WiMax
 Protocol family  Wireless LAN
 Protocol stack  Wireless Local Loop (WLL)
 Protocol suite  Wireless network
 Repeater

Chapter 17: Data Communications & Computer Networks Slide 81/81


Computer Fundamentals : Pradeep K. Sinha & Priti Sinha

Computer Fundamentals

Pradeep K. Sinha
Priti Sinha

Chapter 18

The Internet and


Internet of Things
Chapter 18: The Internet and Internet of Things Slide 1/29
Computer Fundamentals : Pradeep K. Sinha & Priti Sinha

Learning Objectives

In this chapter you will learn about:


 Definition and history of the Internet
 Its basic services
 The World Wide Web (WWW)
 WWW browsers
 Internet search engines
 Uses of the Internet
 Internet of Things (IoT)
 Benefits and Uses of IoT
 Challenges in Adoption of IoT

Chapter 18: The Internet and Internet of Things Slide 2/29


Computer Fundamentals : Pradeep K. Sinha & Priti Sinha

Definition and History

Chapter 18: The Internet and Internet of Things Slide 3/29


Computer Fundamentals : Pradeep K. Sinha & Priti Sinha

Definition and History

 The Internet is a network of computers, which links many


different types of computers all over the world
 It is a network of networks sharing a common mechanism for
addressing computers, and a common set of communication
protocols
 The Internet has its root in the ARPANET system of the
Advanced Research Project Agency of the U.S. Department of
Defense
 ARPANET was the first WAN and had only four sites in 1969
 The Internet evolved from basic ideas of ARPANET for
interconnecting computers

(Continued on next slide)

Ref. Page 396 Chapter 18: The Internet Slide 4/23


Computer Fundamentals : Pradeep K. Sinha & Priti Sinha

Definition and History

 In 1989, the U.S. Government lifted restrictions on the use of


the Internet, and allowed its usage for commercial purposes
as well
 It now interconnects more than 50 Billion devices, and more
than 5 Billion users around the world to communicate with
each other
 The Internet continues to grow at a rapid pace

Ref. Page 396 Chapter 18: The Internet Slide 5/23


Computer Fundamentals : Pradeep K. Sinha & Priti Sinha

Its Basic Services

Chapter 18: The Internet Slide 6/23


Computer Fundamentals : Pradeep K. Sinha & Priti Sinha

Basic Services of the Internet

 Electronic Mail (e-mail): Allows a user to send a mail


(message) to another Internet user in any part of the
world in a near-real-time manner
 File Transfer Protocol (FTP): Allows a user to move a
file from one computer to another on the Internet
 Telnet: Allows a user to log in to another computer
somewhere on the Internet
 Usenet News: Allows a group of users to exchange
their views/ideas/information

Ref. Page 397 Chapter 18: The Internet and Internet of Things Slide 7/29
Computer Fundamentals : Pradeep K. Sinha & Priti Sinha

Electronic Mail

 E-mail is a rapid and productive communication tool


because:
 It is faster than paper mail
 Unlike telephone, the persons communicating with
each other need not be available at the same time
 Unlike fax documents, e-mail documents can be
stored in a computer and be easily edited using
editing programs

Ref. Page 397 Chapter 18: The Internet and Internet of Things Slide 8/29
Computer Fundamentals : Pradeep K. Sinha & Priti Sinha

File Transfer Protocol

 Moving a file from a remote computer to ones own


computer is known as downloading
 Moving a file from ones own computer to a remote
computer is known as uploading
 Anonymous ftp site is a computer allowing a user to log in
with a username of anonymous and password that is
user’s e-mail address.
 Anonymous ftp sites are called publicly accessible sites
because they can be accessed by any user on the Internet

Ref. Page 397 Chapter 18: The Internet and Internet of Things Slide 9/29
Computer Fundamentals : Pradeep K. Sinha & Priti Sinha

Telnet

Some common uses of telnet service are:


 Using the computing power of the remote computer
 Using a software on the remote computer
 Accessing remote computer’s database or archive
 Logging in to ones own computer from another computer

Ref. Page 398 Chapter 18: The Internet and Internet of Things Slide 10/29
Computer Fundamentals : Pradeep K. Sinha & Priti Sinha

Usenet News
 Several usenet news groups exist on the Internet and
are called newsgroups
 In a moderated newsgroup only selected members have
the right to directly post (write) a message to the virtual
notice board. Other members can only read the posted
messages
 In a nonmoderated newsgroup any member can directly
post a message to the virtual notice board
 A moderated newsgroup ensures quality of posted
messages
 Netiquette (network etiquette) deals with rules of
framing messages that will not hurt others

Ref. Page 398 Chapter 18: The Internet and Internet of Things Slide 11/29
Computer Fundamentals : Pradeep K. Sinha & Priti Sinha

The World Wide Web


(WWW)

Chapter 18: The Internet and Internet of Things Slide 12/29


Computer Fundamentals : Pradeep K. Sinha & Priti Sinha

The World Wide Web (WWW)


 World Wide Web (WWW or W3) is the most popular and
promising method of organizing and accessing information on
the Internet
 Hypertext is a new way of information storage and retrieval
that enables authors to structure information in novel ways
 A properly designed hypertext document can help users
locate desired type of information rapidly
 Hypertext documents enable this by using a series of links
 A link is a special type of item in a hypertext document
connecting the document to another document
 Hypertext documents on the Internet are known as Web
Pages
(Continued on next slide…)

Ref. Page 399 Chapter 18: The Internet Slide 13/23


Computer Fundamentals : Pradeep K. Sinha & Priti Sinha

The World Wide Web (WWW)


 Web page designers create Web Pages by using a special
language called HyperText Markup Language (HTML)
 HTML is a subset of a more generalized language called
Standard Generalized Markup Language (SGML)
 HTML is now a de-facto industrial standard for creating Web
Pages
 The WWW uses client-server model, and an Internet Protocol
called HyperText Transport Protocol (HTTP)
 Any computer on the Internet using the HTTP protocol is
called a Web Server
 Any computer accessing that server is called a Web Client

Ref. Page 400 Chapter 18: The Internet Slide 14/23


Computer Fundamentals : Pradeep K. Sinha & Priti Sinha

Example of Hypertext Document

Pradeep K. Sinha has been involved in the research and


development of distributed systems for more than three
decades. In addition to being the founding Vice
Chancellor and Director of IIIT-Raipur, Dr. Sinha has Links
worked with the Centre for Development of
Advanced Computing (C-DAC), Pune, India and the
Multimedia Systems Research Laboratory (MSRL)
of Panasonic in Tokyo, Japan.

Ref. Page 399 Chapter 18: The Internet and Internet of Things Slide 15/29
Computer Fundamentals : Pradeep K. Sinha & Priti Sinha

WWW Browsers
 To use a computer as a web client, a user needs to load on it
a special software tool known as WWW browser (browser)
 Browsers provide following navigation facilities:
 Do not require a user to log in to a server computer
 Enable a user to visit a server computer’s site directly and
access information on it by specifying its URL (Uniform
Resource Locator)
 Enable a user to create and maintain a personal hotlist of
favorite URL
 Maintain a history of server computers visited by a user in a
surfing session
 Enable a user to download information in various formats

Ref. Page 400 Chapter 18: The Internet Slide 16/23


Computer Fundamentals : Pradeep K. Sinha & Priti Sinha

Internet Search Engines

Chapter 18: The Internet Slide 17/23


Computer Fundamentals : Pradeep K. Sinha & Priti Sinha

Internet Search Engines


 Internet search engine is an application, which helps users
locate web sites containing useful information and references
 To search information:
 A user types the description of the information using the user
interface of the search engine
 The search engine then searches the requested information on
the WWW and returns the results to the user
 Results enable the user to locate the requested information
quickly from the vast ocean of information available on the
Internet

Ref. Page 401 Chapter 18: The Internet Slide 18/23


Computer Fundamentals : Pradeep K. Sinha & Priti Sinha

Major Elements of Internet Search Engines

 Search Request Interface


 Enables users to provide description of desired information to
the search engine
 Search engine may allow specifications of simple keywords and
phrases, combination of keywords and phrases using Boolean
operators and exclusion/inclusion operators, and title and URL
limiters
 Information Discoverer
 Discovers information from the WWW and creates a database
for the search engine
 Search engine uses the database to locate useful information
during the search process
 Information discoverer accrues this information in two-ways:
 In manual method, authors provide information about their
websites (Continued on next slide…)

Ref. Page 401 Chapter 18: The Internet Slide 19/23


Computer Fundamentals : Pradeep K. Sinha & Priti Sinha

Major Elements of Internet Search Engines

 In automatic method, information discoverer collects the


information using programs, such as web crawlers, spiders, robots

 Presenter of Search Results


 Returns search results, ranking them in an order
 Search engines often list search results in accordance to a
relevance score
 Relevance scores reflect the number of times a search term
appears in a web page
 Some search engines also allow users to control relevance
score by giving different weights

Ref. Page 401 Chapter 18: The Internet Slide 20/23


Computer Fundamentals : Pradeep K. Sinha & Priti Sinha

Some Popular Internet Search Engines

 Google (www.google.com)
 Yahoo (www.yahoo.com)
 Lycos (www.lycos.com)
 Infoseek (www.infoseek.com)
 HotBot (www.hotbot.com)
 Inference Find (www.infind.com)
 Ixquick (www.ixquick.com)

Ref. Page 401 Chapter 18: The Internet Slide 21/23


Computer Fundamentals : Pradeep K. Sinha & Priti Sinha

Uses of the Internet


Some important current strategic uses of the Internet are:
 On-line communication
 Software sharing
 Exchange of views on topics of common interest
 Posting of information of general interest
 Organization promotion
 Product promotion and feedback about products
 Customer support service
 On-line journals, magazines, encyclopedia, and
dictionary
 On-line shopping
 World-wide video conferencing
 World-wide web casting

Ref. Page 401 Chapter 18: The Internet and Internet of Things Slide 22/29
Computer Fundamentals : Pradeep K. Sinha & Priti Sinha

Internet of Things

Chapter 18: The Internet and Internet of Things Slide 23/29


Computer Fundamentals : Pradeep K. Sinha & Priti Sinha

What It Is?

IoT is enhanced form of the Internet, in which the enhancement


takes care of the following two objectives:

1. Interconnection of things, in addition to computing


devices, and

2. Automatic collection and transfer of data, without any help


from human being

Ref. Page 403 Chapter 18: The Internet and Internet of Things Slide 24/29
Computer Fundamentals : Pradeep K. Sinha & Priti Sinha

Things in IoT?

• Refers to any object (device) with any kind of built-in sensors


and having the ability to collect and transfer data over a
network without manual intervention

• Also known as Smart Objects

Ref. Page 403 Chapter 18: The Internet and Internet of Things Slide 25/29
Computer Fundamentals : Pradeep K. Sinha & Priti Sinha

Benefits of IoT

• Increased accuracy

• Increased efficiency

• Reduced wastage

• Improved customer satisfaction

Ref. Page 403 Chapter 18: The Internet and Internet of Things Slide 26/29
Computer Fundamentals : Pradeep K. Sinha & Priti Sinha

IoT Applications (Uses of IoT)

• IoT is used in many sectors with millions of applications

• A few examples of IoT applications are:


 Smart home
 Smart city
 Smart healthcare
 Smart energy management
 Smart transportation system
 Smart agriculture/farming
 Smart manufacturing/industry (Industry 4.0)

Ref. Page 404 Chapter 18: The Internet and Internet of Things Slide 27/29
Computer Fundamentals : Pradeep K. Sinha & Priti Sinha

Challenges in Adoption of IoT

1. Interoperability issue

2. Issue of designing smart “things”

3. Unstructured data handling issue

4. Security and privacy issue

5. Reliability issue

Ref. Page 407 Chapter 18: The Internet and Internet of Things Slide 28/29
Computer Fundamentals : Pradeep K. Sinha & Priti Sinha

Keywords/Phrases
 Anonymous ftp site  Smart healthcare
 Browser  Smart home
 Download  Smart manufacturing
 Electronic mail (e-mail)  Smart objects
 File Transfer Protocol (FTP)  Smart transportation system
 Hypertext  Standard Generalized Markup
 Hypertext Transport Protocol (HTTP) Language (SGML)
 Industry 4.0  Telnet
 Internet  Things
 Internet of Things (IoT)  Uniform Resource Locator (URL)
 Internet search engine  Upload
 Netiquette  Usenet
 Newsgroup  Video conferencing
 On-line shopping  Web casting
 Publicly accessible sites  Web client
 Smart agriculture/farming  Web crawler
 Smart city  Web Server
 Smart energy management  World Wide Web (WWW)

Chapter 18: The Internet and Internet of Things Slide 29/29


Computer Fundamentals : Pradeep K. Sinha & Priti Sinha

Computer Fundamentals

Pradeep K. Sinha
Priti Sinha

Chapter 19

Multimedia
Chapter 19: Multimedia Slide 1/36
Computer Fundamentals : Pradeep K. Sinha & Priti Sinha

Learning Objectives

In this chapter you will learn about:


 What is multimedia?
 What is a multimedia computer system?
 Main components of multimedia and their associated
technologies
 Common multimedia applications
 Media center computer

Chapter 19: Multimedia Slide 2/36


Computer Fundamentals : Pradeep K. Sinha & Priti Sinha

What is Multimedia?

Chapter 19: Multimedia Slide 3/36


Computer Fundamentals : Pradeep K. Sinha & Priti Sinha

Multimedia

 A medium (plural media) is something that a presenter can


use for presentation of information
 Two basic ways to present information are:
 Unimedium presentation: Presenter uses a single
medium to present information
 Multimedia presentation: Presenter uses more than one
medium to present information
 Multimedia presentation of any information enhances
comprehension capability of its user because it involves use of
multiple senses by the user

Ref. Page 410 Chapter 19: Multimedia Slide 4/36


Computer Fundamentals : Pradeep K. Sinha & Priti Sinha

Common Media
 Common media for storage, access, and transmission of
information are:
 Text (alphanumeric characters)
 Graphics (line drawings and images)
 Animation (moving images)
 Audio (sound)
 Video (Videographed real-life events)
 Multimedia in information technology refers to use of more
than one of these media for information presentation to
users

Ref. Page 411 Chapter 19: Multimedia Slide 5/36


Computer Fundamentals : Pradeep K. Sinha & Priti Sinha

Multimedia Computer System


 Multimedia computer system is a computer having
capability to integrate two or more types of media (text,
graphics, animation, audio, and video)
 In general, data size for multimedia information is much
larger than plain text information
 Hence, multimedia computer systems require:
 Faster CPU
 Larger storage devices (for storing large data files)
 Larger main memory (for large data size)
 Good graphics terminals
 I/O devices to play any multimedia

(Continued on next slide)

Ref. Page 411 Chapter 19: Multimedia Slide 6/36


Computer Fundamentals : Pradeep K. Sinha & Priti Sinha

Multimedia Components

Chapter 19: Multimedia Slide 7/36


Computer Fundamentals : Pradeep K. Sinha & Priti Sinha

Text Media
 Alphanumeric characters are used to present information
in text form. Computers are widely used for text
processing
 Keyboards, electronic writing pads, OCRs, terminal
screens, and printers are some commonly used
hardware devices for processing text media
 Text editing, text searching, hypertext, and text
importing/exporting are some highly desirable features
of a multimedia computer system for better presentation
and use of text information

Ref. Page 412 Chapter 19: Multimedia Slide 8/36


Computer Fundamentals : Pradeep K. Sinha & Priti Sinha

Graphics

 Computer graphics deals with tools and technologies for


generating, representing, manipulating, and displaying
pictures with a computer
 Graphics is an important component of multimedia
applications because a picture is a powerful way to illustrate
information

Ref. Page 413 Chapter 19: Multimedia Slide 9/36


Computer Fundamentals : Pradeep K. Sinha & Priti Sinha

Graphics Types
 Line drawings
 Drawings are illustrations in the form of 2D and 3D pictures
created from mathematical representation of simple objects like
lines, circles, arcs, etc.
 Area of computer graphics that deals with this type of pictures is
known as generative graphics
 Images
 Computers store pixels of an image as a two-dimensional matrix
 This two-dimensional representation is called image resolution
 Each pixel is composed of three components: red (R), green (G),
blue (B)
 On a display screen, each component of a pixel corresponds to a
phosphor
(Continued on next slide…)

Ref. Page 413 Chapter 19: Multimedia Slide 10/36


Computer Fundamentals : Pradeep K. Sinha & Priti Sinha

Graphics Types

 Phosphor glows when excited by an electron gun


 Number of bits used to represent a pixel is called color depth
 Color depth in turn is determined by the size of video buffer in
display circuitry
 Resolution and color depth determine the presentation quality
and size of image storage
 Applications use image compression techniques to compress
images to reduce their size before storing or transmitting them
 Area of computer graphics that deals with this type of pictures
is known as cognitive graphics

Ref. Page 413 Chapter 19: Multimedia Slide 11/


Computer Fundamentals : Pradeep K. Sinha & Priti Sinha

An Image Composition

Image sample Divided into pixels A pixel composition

R G

Ref. Page 414 Chapter 19: Multimedia Slide 12/


Computer Fundamentals : Pradeep K. Sinha & Priti Sinha

Graphics: Hardware Requirements

 Locating device with a video display terminal and


drawing software
 Flatbed or rectangular coordinate digitizer
 Scanners
 Digital camera or frame-capture hardware
 Computer screens with graphics display capability
 Laser printers
 Plotters

Ref. Page 414 Chapter 19: Multimedia Slide 13/


Computer Fundamentals : Pradeep K. Sinha & Priti Sinha

Graphics: Software Requirements

 Drawing and painting software


 Screen-capture software
 Clip art
 Graphics importing
 Software support for high resolution

Ref. Page 414 Chapter 19: Multimedia Slide 14/


Computer Fundamentals : Pradeep K. Sinha & Priti Sinha

Animation Media
 Computer animation deals with generation, sequencing,
and display (at a specified rate) of a set of images
(called frames) to create an effect of visual change or
motion, similar to a movie film (video)
 Animation is commonly used in those instances where
videography is not possible or animation can better
illustrate the concept than video
 Animation deals with displaying a sequence of images at
a reasonable speed to create an impression of
movement. For a jerk-free full motion animation, 25 to
30 frames per second is required

Ref. Page 415 Chapter 19: Multimedia Slide 15/36


Computer Fundamentals : Pradeep K. Sinha & Priti Sinha

Animation: Hardware Requirements

 Image generation tools and devices such as scanners, digital


cameras, and video capture board
 Computer monitor with image display capability and a
graphics accelerator board

Ref. Page 415 Chapter 19: Multimedia Slide 16/36


Computer Fundamentals : Pradeep K. Sinha & Priti Sinha

Animation: Software Requirements

 Animation-creation software
 Screen-capture software
 Animation clips
 Animation file importing
 Software support for high resolution
 Recording and playback capability
 Transition effects

Ref. Page 416 Chapter 19: Multimedia Slide 17/36


Computer Fundamentals : Pradeep K. Sinha & Priti Sinha

Virtual Reality

 Virtual reality is a relatively new technology using


which the user can put a pair of goggles and a glove
and tour a three-dimensional world that exists only in
the computer, but appears realistic to the user
 Virtual reality applications use animation extensively

Ref. Page 416 Chapter 19: Multimedia Slide 18/36


Computer Fundamentals : Pradeep K. Sinha & Priti Sinha

Audio

 Computer audio deals with tools and technologies for


synthesizing, recording, and playing of audio or sound with a
computer

Ref. Page 417 Chapter 19: Multimedia Slide 19/36


Computer Fundamentals : Pradeep K. Sinha & Priti Sinha

Analog and Digital Audio


 Audio information travels in natural medium in the form of
sound waves that are analog
 To enable a computer to deal with audio information, a device
must convert sound waves from analog to digital form
 Transducer is a device that converts signals from one form to
another
 Microphone is a transducer that converts sound waves to
electrical signals, and loudspeaker is a transducer that
converts electrical signals to sound waves
 Analog signals are continuous tone of smooth fluctuations,
while digital signals are discrete values in the form of
numbers

Ref. Page 417 Chapter 19: Multimedia Slide 20/36


Computer Fundamentals : Pradeep K. Sinha & Priti Sinha

Analog and Digital Audio

 A/D conversion transforms an analog input into a series of


numeric representation by digitization
 D/A conversion is the reverse process of transforming a
sequence of discrete numbers back into continuous analog
signal

Ref. Page 417 Chapter 19: Multimedia Slide 21/36


Computer Fundamentals : Pradeep K. Sinha & Priti Sinha

Roles of A/D and D/A Converters


Analog data A
input device A/D
converter
D

Secondary Network
Memory
storage I/O

D
Data in analog form
D/A
converter Analog data
Data in digital form
A output device

Ref. Page 417 Chapter 19: Multimedia Slide 22/36


Computer Fundamentals : Pradeep K. Sinha & Priti Sinha

Audio Processing

 Audio processing requires a sound-board which has:


 A/D and D/A converters
 Connector for a speaker or headphone
 MIDI input port to input sound from an external MIDI device
 MIDI output port to output recorded sound to the MIDI
device
 MIDI synthesizer
 Volume control

Ref. Page 418 Chapter 19: Multimedia Slide 23/36


Computer Fundamentals : Pradeep K. Sinha & Priti Sinha

Audio: Hardware Requirements

 Sound-board with A/D and D/A converters


 Input device for audio input to record sound
 Output device to listen audio output
 Computer may use MIDI devices
 Computer may also enable generation of synthesized
sound by using keyboard
 Sound editors enable cut and paste of sound sequences
 Audio mixers enable combining of multiple channels of
sound with controls like synchronization points

Ref. Page 418 Chapter 19: Multimedia Slide 24/36


Computer Fundamentals : Pradeep K. Sinha & Priti Sinha

Audio: Software Requirements

 Audio clips
 Audio file importing
 Software support for high quality sound
 Recording and playback capability
 Text-to-speech conversion software
 Speech-to-text conversion software
 Voice recognition software

Ref. Page 418 Chapter 19: Multimedia Slide 25/36


Computer Fundamentals : Pradeep K. Sinha & Priti Sinha

Video

 Video deals with tools and technologies for recording and


displaying a sequence of images (frames) at a reasonable
speed to create an impression of motion
 For jerk-free full motion video, the display device must
display 25 to 30 frames per second
 Video is an important component of multimedia
applications because it is useful for illustrating concepts
involving movement

Ref. Page 419 Chapter 19: Multimedia Slide 26/36


Computer Fundamentals : Pradeep K. Sinha & Priti Sinha

Analog and Digital Video

 Video information travels in natural medium in the form of


light waves that are analog
 To enable a computer to deal with video information, a device
must convert light waves from analog to digital form
 Video camera is a transducer that converts light waves to
electrical signals, and monitor is a transducer that converts
electrical signals to light waves
 Analog-to-digital conversion of video also involves sampling
and quantization of analog video signals

Ref. Page 419 Chapter 19: Multimedia Slide 27/36


Computer Fundamentals : Pradeep K. Sinha & Priti Sinha

Video: Hardware Requirements

 Video camera
 Video monitor
 Video board with A/D and D/A converters, and
connectors for video camera and video monitor
 Video editors

Ref. Page 419 Chapter 19: Multimedia Slide 28/36


Computer Fundamentals : Pradeep K. Sinha & Priti Sinha

Video: Software Requirements

 Video clips
 It is a library of video clips
 A user can import a video clip directly from this library for
use in a multimedia application
 Recording and playback capability
 Enables users to control recording and display of a video
sequence

Ref. Page 419 Chapter 19: Multimedia Slide 29/36


Computer Fundamentals : Pradeep K. Sinha & Priti Sinha

Multimedia Applications

Chapter 19: Multimedia Slide 30/36


Computer Fundamentals : Pradeep K. Sinha & Priti Sinha

Multimedia Applications
 Multimedia books and e-Books
 Digital library
 Multimedia presentation
 Foreign language learning
 Video games
 Special effects in movies
 Animation films
 Animated advertisements
 Multimedia kiosk
 Virtual shops and shopping malls
 Multimedia conferencing
 Smart/Interactive TV

Ref. Page 420 Chapter 19: Multimedia Slide 31/36


Computer Fundamentals : Pradeep K. Sinha & Priti Sinha

A Video-on-Demand System

Disks
Set-top box
Remote
control

Tapes
TV monitor

Video server
Customer’s home

Switch Transport Switch


network

Ref. Page 423 Chapter 19: Multimedia Slide 32/36


Computer Fundamentals : Pradeep K. Sinha & Priti Sinha

Media Center Computer

Chapter 19: Multimedia Slide 33/36


Computer Fundamentals : Pradeep K. Sinha & Priti Sinha

Media Center Computer


 There is a growing trend of owning a personal computer
(PC) at home like other electronic equipment
 New terminologies like “infotainment” and “edutainment”
have evolved to refer to computers as versatile tools
 Media center PC provides following functionalities:
 Server as PC, TV, radio, and music system
 Serve as digital photo album and digital library
 Server as Game station and DVD/CD Player
 Allows play, pause, and record of TV programs
 Provides Electronic Programming Guide (EPG)

(Continued on next slide…)

Ref. Page 423 Chapter 19: Multimedia Slide 34/36


Computer Fundamentals : Pradeep K. Sinha & Priti Sinha

Media Center Computer


 Any PC with good graphics display card, multimedia
components, and a TV tuner card can serve as a media
center PC by installing media center applications on it
 Some operating systems provide features of media centre
applications integrated into OS itself
 Such operating systems are called media center OS

High-resolution display screen


System unit
Remote control

Mouse
Keyboard

Ref. Page 424 Chapter 19: Multimedia Slide 35/36


Computer Fundamentals : Pradeep K. Sinha & Priti Sinha

Keywords/Phrases
 Animation
 Audio
 Clip art
 Cognitive graphics
 Computer Aided Design (CAD)
 Computer Aided Manufacturing (CAM)
 Digital library
 Frames
 Generative graphics
 Graphics
 Interactive TV
 Multimedia
 Media Center Computer
 Pixel
 Refresh rate
 Text
 Transducer
 Transition effects
 Unimedia presentation
 Video
 Virtual reality

Chapter 19: Multimedia Slide 36/36


Computer Fundamentals : Pradeep K. Sinha & Priti Sinha

Computer Fundamentals

Pradeep K. Sinha
Priti Sinha

Chapter 20

Classification of
Computers
Chapter 20: Classification of Computers Slide 1/33
Computer Fundamentals : Pradeep K. Sinha & Priti Sinha

Learning Objectives

In this chapter you will learn about:

 Classifications of computers
 Common types of computers used today
 Characteristic features of various types of
computers in use today

Chapter 20: Classification of Computers Slide 2/33


Computer Fundamentals : Pradeep K. Sinha & Priti Sinha

Computer Classification

 Traditionally, computers were classified by their size,


processing speed, and cost
 Based on these factors, computers were classified as
microcomputers, minicomputers, mainframes, and
supercomputers
 However, with rapidly changing technology, this
classification is no more relevant
 Today, computers are classified based on their mode
of use

Ref. Page 428 Chapter 20: Classification of Computers Slide 3/33


Computer Fundamentals : Pradeep K. Sinha & Priti Sinha

Types of Computers

Based on their mode of use, computers are classified as:


 Notebook computers (Laptops)
 Personal computers (PCs)
 Workstations
 Mainframe systems
 Supercomputers
 Client and server computers
 Handheld computers

Ref. Page 428 Chapter 20: Classification of Computers Slide 4/33


Computer Fundamentals : Pradeep K. Sinha & Priti Sinha

Notebook Computers
(Laptops)

Chapter 20: Classification of Computers Slide 5/33


Computer Fundamentals : Pradeep K. Sinha & Priti Sinha

Notebook Computers
 Portable computers mainly meant for use by people who
need computing resource wherever they go
 Approximately of the size of an 8½ x 11 inch notebook and
can easily fit inside a briefcase
 Weigh only around 2 kg or less.
 Comfortably placed on ones lap while being used. Hence,
they are also called laptop PCs.
 Lid with display screen is foldable in a manner that when
not in use it can be folded to flush with keyboard to
convert the system into notebook form

(Continued on next slide)

Ref. Page 428 Chapter 20: Classification of Computers Slide 6/33


Computer Fundamentals : Pradeep K. Sinha & Priti Sinha

Notebook Computers
 Designed to operate with chargeable batteries
 Mostly used for word processing, spreadsheet
computing, data entry, and power point presentations
 Normally run MS-DOS, MS WINDOWS Mac OS, or Linux
operating system
 Some manufacturers are also offering models with
GNU/Linux or its distributions
 Each device of laptop is designed to use little power and
remain suspended if not used

Ref. Page 428 Chapter 20: Classification of Computers Slide 7/33


Computer Fundamentals : Pradeep K. Sinha & Priti Sinha

Notebook Computers

Foldable flat screen

Keyboard, trackball, hard


disk, I/O ports, etc. are in
this unit

Ref. Page 429 Chapter 20: Classification of Computers Slide 8/33


Computer Fundamentals : Pradeep K. Sinha & Priti Sinha

Personal Computers (PCs)

Chapter 20: Classification of Computers Slide 9/33


Computer Fundamentals : Pradeep K. Sinha & Priti Sinha

Personal Computers (PCs)


 Non-portable, general-purpose computer that fits on a
normal size office table
 Designed to meet personal computing needs of individuals
 Often used by children and adults for education and
entertainment also
 Generally used by one person at a time, supports
multitasking
 Two common models of PCs are desktop model and tower
model
 Popular OS are MS-DOS, MS-Windows, Windows-NT, Mac
OS, Linux, and UNIX

Ref. Page 429 Chapter 20: Classification of Computers Slide 10/33


Computer Fundamentals : Pradeep K. Sinha & Priti Sinha

Common PC Models

Monitor

System
Unit Mouse

Mouse

Keyboard
(a) Desktop model (b) Tower model

Ref. Page 430 Chapter 20: Classification of Computers Slide 11/33


Computer Fundamentals : Pradeep K. Sinha & Priti Sinha

Workstations

Chapter 20: Classification of Computers Slide 12/33


Computer Fundamentals : Pradeep K. Sinha & Priti Sinha

Workstations
 Powerful desktop computer designed to meet the
computing needs of engineers, architects, and other
professionals
 Provides greater processing power, larger storage, and
better graphics display facility than PCs
 Commonly used for computer-aided design, multimedia
applications, simulation of complex scientific and
engineering problems, and visualization
 Generally run server version of Windows, Mc OS, Linux, or
UNIX operating system
 Operating system is generally designed to support
multiuser environment

Ref. Page 431 Chapter 20: Classification of Computers Slide 13/33


Computer Fundamentals : Pradeep K. Sinha & Priti Sinha

Mainframe Systems

Chapter 20: Classification of Computers Slide 14/33


Computer Fundamentals : Pradeep K. Sinha & Priti Sinha

Mainframe Systems
 Mainly used by large organizations as banks, insurance
companies, hospitals, railways, etc.
 Used for data handling and information processing
requirements
 Used in such environments where a large number of
users need to share a common computing facility
 Oriented to input/output-bound applications

(Continued on next slide)

Ref. Page 431 Chapter 20: Classification of Computers Slide 15/33


Computer Fundamentals : Pradeep K. Sinha & Priti Sinha

Mainframe Systems

 Typically consist of a host computer, front-end


computer, back-end computer, console terminals,
magnetic disk drives, tape drives, magnetic tape library,
user terminals, printers, and plotters
 Typical mainframe system looks like a row of large file
cabinets and needs a large room
 Smaller configuration (slower host and subordinate
computers, lesser storage space, and fewer user
terminals) is often referred to as a minicomputer
system

Ref. Page 431 Chapter 20: Classification of Computers Slide 16/33


Computer Fundamentals : Pradeep K. Sinha & Priti Sinha

Mainframe Computer Systems


USERS ROOM
(Entry restricted to authorized users)
SYSTEM ROOM
(Entry restricted to system administrators and maintenance staff)
Magnetic tape library Magnetic tape
Magnetic drive
disk drives

Back end processor


Plotter

Host processor
Printer
Console

Front-end processor

User terminal User terminal User terminal

Ref. Page 433 Chapter 20: Classification of Computers Slide 17/33


Computer Fundamentals : Pradeep K. Sinha & Priti Sinha

Supercomputers

Chapter 20: Classification of Computers Slide 18/33


Computer Fundamentals : Pradeep K. Sinha & Priti Sinha

Supercomputers
 Most powerful and most expensive computers available at
a given time.
 Primarily used for processing complex scientific
applications that require enormous processing power
 Well known supercomputing applications include:
 Analysis of large volumes of seismic data
 Simulation of airflow around an aircraft
 Crash simulation of the design of an automobile
 Solving complex structure engineering problems
 Weather forecasting
 Creating special effects for movies and TV programs
(Continued on next slide)

Ref. Page 433 Chapter 20: Classification of Computers Slide 19/33


Computer Fundamentals : Pradeep K. Sinha & Priti Sinha

Supercomputers

 Supercomputers also support multiprogramming


 Supercomputers primarily address processor-bound
applications

Ref. Page 433 Chapter 20: Classification of Computers Slide 20/33


Computer Fundamentals : Pradeep K. Sinha & Priti Sinha

Parallel Processing Systems

 Use multiprocessing and parallel processing


technologies to solve complex problems faster
 Also known as parallel computers or parallel processing
systems
 Modern supercomputers employ hundreds of processors
and are also known as massively parallel processors

Ref. Page 434 Chapter 20: Classification of Computers Slide 21/33


Computer Fundamentals : Pradeep K. Sinha & Priti Sinha

C-DAC’s PARAM Yuva Supercomputer

Ref. Page 435 Chapter 20: Classification of Computers Slide 22/33


Computer Fundamentals : Pradeep K. Sinha & Priti Sinha

Client and Server


Computers

Chapter 20: Classification of Computers Slide 23/33


Computer Fundamentals : Pradeep K. Sinha & Priti Sinha

Client and Server Computers


 Client-server computing environment has multiple
clients, one/more servers, and a network
 Client is a PC/workstation with user-friendly interface
running client processes that send service requests to
the server
 Server is generally a relatively large computer that
manages a shared resource and provides a set of
shared user services to the clients
 Server runs the server process that services client
requests for use of managed resources
 Network may be a single LAN or WAN or an internet
work

Ref. Page 435 Chapter 20: Classification of Computers Slide 24/33


Computer Fundamentals : Pradeep K. Sinha & Priti Sinha

Client-Server Computing
 Involves splitting an application into tasks and putting
each task on computer where it can be handled most
efficiently
 Computers and operating systems of a client and a
server may be different
 Common for one server to use the services of another
server, and hence act both as client and server
 Concept of client and server computers is purely role-
based and may change dynamically as the role of a
computer changes

Ref. Page 435 Chapter 20: Classification of Computers Slide 25/33


Computer Fundamentals : Pradeep K. Sinha & Priti Sinha

Client-Server Computing Environment

PC (Client)
PC (Client) File
Server
LAN or WAN or an
Internet of Networks

PC (Client)

Database
Server

Workstation
(Client)
Workstation
(Client)

Ref. Page 436 Chapter 20: Classification of Computers Slide 26/33


Computer Fundamentals : Pradeep K. Sinha & Priti Sinha

Handheld Computers

Chapter 20: Classification of Computers Slide 27/33


Computer Fundamentals : Pradeep K. Sinha & Priti Sinha

Handheld Computers

 Small computing device that can be used by holding in


hand, also known as palmtop
 Size, weight, and design are such that it can be used
comfortably by holding in hand
 Types of Handheld are:
 Tablet PC: Miniaturized laptop with light weight, screen
flip, handwriting and voice recognition
 PDA/Pocket PC: Acts as PIM device with LCD touch
screen, pen for handwriting recognition, PC based
synchronization, and optionally mobile phone services
 Smartphone: Fully functional mobile phone with
computing power, voice centric, do not have a touch
screen and are smaller than PDA

Ref. Page 436 Chapter 20: Classification of Computers Slide 28/33


Computer Fundamentals : Pradeep K. Sinha & Priti Sinha

Handheld Computers

(a) Tablet PC (b) PDA/Pocket PC (c) Smartphone

Ref. Page 438 Chapter 20: Classification of Computers Slide 29/33


Computer Fundamentals : Pradeep K. Sinha & Priti Sinha
Comparison of Different Types of
Computers

Key features

Super
Personal Mainframe
Notebook Workstation compute Client Server Handheld
Computer system
Types of r
computers

Size Very small Small Medium Large Large Generally Generally Very small (can
(can be (can be placed (Slightly larger (needs a (needs a small large be placed on
placed on an office than PC) large room) large (may be ones palm)
on ones lap) table) room) large if it
also plays
the role of a
server)

Processing power Low Low High Higher Highest Generally Generally high Low
low
Main memory Low Low High Higher Highest Generally Generally high Low
capacity low
Hard disk storage Low Low High Highest Higher Generally Generally high Low
capacity low

Has its own Yes Yes Yes Generally Generally Yes Generally no No
monitor, keyboard, no no
and mouse for
user interface

Ref. Page 439 Chapter 20: Classification of Computers Slide 30/33


Computer Fundamentals : Pradeep K. Sinha & Priti Sinha
Comparison of Different Types of
Computers

Key features

Super
Personal Mainframe
Notebook Workstation compute Client Server Handheld
Computer system
Types of r
computers

Display facility Foldable Medium size Large-screen Generally Generally Medium to Generally not Small display
flat screen display screen display that can not not large available
small display high- available available screen
display resolution display
graphics

Single/multiple Single Generally Generally multiple Multiple Multiple Generally Generally Single
processors single single multiple
Single/multiple Single Single Generally single Multiple Multiple Single Multiple Single
- User oriented
Popular MS-DOS, MS-DOS, Server version of A variant of A variant MS-DOS, Server MS-Wndows
operating MS- MS-Windows, Windows, Mac OS, Unix, or of Unix, MS- version of Mobile, iOS,
systems Windows, Windows-NT, Linux or Unix proprietary or Windows, Windows, Palm OS,
Mac OS, Mac OS, proprieta Windows- Mac OS, Symbian OS,
Linux Linux, ry NT, Linux or Unix Linux,
Unix Mac OS, Blackbery OS
Linux,
Unix

Ref. Page 439 Chapter 20: Classification of Computers Slide 31/33


Computer Fundamentals : Pradeep K. Sinha & Priti Sinha
Comparison of Different Types of
Computers

Key features

Personal Mainframe Super


Notebook Workstation Client Server Handheld
Computer system computer
Types of
computers

Popular usage Word Personal Computing needs Processing Large Provide Manage a Computing,
processing; computing of engineers, of I/O- processor- highly user- shared Personal
Spreadsheet; needs of architects, bound bound friendly resource Information
Data Entry; individuals designers; applications applica- interface in and Management
Preparing either at Simulation of tions like a client- provide a (PIM), cell
presentation their work complex scientific complex server set of phone, digital
materials; places or at and engineering scientific computing shared camera
and Making their homes; problems and simulations environment user
presentations and visualizing the services in
Education results of a client-
and simulation; and server
entertainme Multimedia computing
nt of applications environm
children and ent
adults
Major vendors IBM, IBM, Apple, Sun IBM, DEC Cray, IBM, Same as PC Same as Nokia, Sony,
Compaq, Compaq, Microsystems, Silicon and Workstati Apple,
Siemens, Dell, IBM, DEC, Graphics, Workstation on, Samsung,
Apple, Siemens, Hewlett-Packard, Fujitsu, vendors Mainframe Motorola, Dell,
Toshiba Toshiba, Silicon Graphics Intel, System, Hawlett-
Hewlett- C-DAC and Packard
Packard, Supercom
Lenovo puter
vendors

Ref. Page 439 Chapter 20: Classification of Computers Slide 32/33


Computer Fundamentals : Pradeep K. Sinha & Priti Sinha

Key Words/Phrases
 Back-end computer
 Client computer
 Client process
 Front-end computer
 Host computer
 Handheld
 I/O-bound application
 Laptop PC
 Mainframe system
 Massively parallel processors
 Minicomputer
 Notebook computer
 Parallel computers
 Parallel processing system
 Personal Computer (PC)
 Processor-bound application
 Server computer
 Server process
 Supercomputer
 System board
 Workstation

Chapter 20: Classification of Computers Slide 33/33


Computer Fundamentals : Pradeep K. Sinha & Priti Sinha

Computer Fundamentals

Pradeep K. Sinha
Priti Sinha

Chapter 21

Introduction to C
Programming
Language
Chapter 21: Introduction to C Programming Languages Slide 1/76
Computer Fundamentals : Pradeep K. Sinha & Priti Sinha

Learning Objectives

In this chapter you will learn about:


 Features of C
 Various constructs and their syntax
 Data types and operators in C
 Control and Loop Structures in C
 Functions in C
 Writing programs in C

Chapter 21: Introduction to C Programming Languages Slide 2/76


Computer Fundamentals : Pradeep K. Sinha & Priti Sinha

Basic Features and Rules

Chapter 21: Introduction to C Programming Languages Slide 3/76


Computer Fundamentals : Pradeep K. Sinha & Priti Sinha

Features of C

 Reliable, simple, and easy to use


 Has virtues of high-level programming language with
efficiency of assembly language
 Supports user-defined data types
 Supports modular and structured programming concepts
 Supports a rich library of functions
 Supports pointers with pointer operations
 Supports low-level memory and device access
 Small and concise language
 Standardized by several international standards body

Ref. Page 442 Chapter 21: Introduction to C Programming Languages Slide 4/76
Computer Fundamentals : Pradeep K. Sinha & Priti Sinha

C Character Set

Category Valid Characters Total

Uppercase alphabets A, B, C, …, Z 26

Lowercase alphabets a, b, c, …, z 26

Digits 0, 1, 2, …, 9 10

~ `! @ # % ^ & * ( ) _ 
Special characters 31
  | \ {}[ ]:; " '   , . ? /

93

Ref. Page 443 Chapter 21: Introduction to C Programming Languages Slide 5/76
Computer Fundamentals : Pradeep K. Sinha & Priti Sinha

Constants

 Constant is a value that never changes


 Three primitive types of constants supported in C are:
 Integer
 Real
 Character

Ref. Page 443 Chapter 21: Introduction to C Programming Languages Slide 6/76
Computer Fundamentals : Pradeep K. Sinha & Priti Sinha
Rules for Constructing Integer
Constants
 Must have at least one digit
 + or – sign is optional
 No special characters (other than + and – sign) are
allowed
 Allowable range is:
 -32768 to 32767 for integer and short integer
constants (16 bits storage)
 -2147483648 to 2147483647 for long integer
constants (32 bits storage)
 Examples are: 8, +17, -6

Ref. Page 444 Chapter 21: Introduction to C Programming Languages Slide 7/76
Computer Fundamentals : Pradeep K. Sinha & Priti Sinha
Rules for Constructing Real
Constants in Fractional Form

 Must have at least one digit


 Must have one and only one decimal point
 + or – sign is optional
 No special characters (other than + and – sign) are
allowed
 Examples are: 5.3, +18.59, -0.46

Ref. Page 444 Chapter 21: Introduction to C Programming Languages Slide 8/76
Computer Fundamentals : Pradeep K. Sinha & Priti Sinha
Rules for Constructing Real Constants
in Exponential Form

 Has two parts – mantissa and exponent - separated by


‘e’ or ‘E’
 Mantissa part is constructed by the rules for constructing
real constants in fractional form
 Exponent part is constructed by the rules for
constructing integer constants
 Allowable range is -3.4e38 to 3.4e38
 Examples are: 8.6e5, +4.3E-8, -0.1e+4

Ref. Page 444 Chapter 21: Introduction to C Programming Languages Slide 9/76
Computer Fundamentals : Pradeep K. Sinha & Priti Sinha
Rules for Constructing Character
Constants

 Single character from C character set


 Enclosed within single inverted comma (also
called single quote) punctuation mark
 Examples are: ’A’ ’a’ ’8’ ’%’

Ref. Page 444 Chapter 21: Introduction to C Programming Languages Slide 10/76
Computer Fundamentals : Pradeep K. Sinha & Priti Sinha

Variables
 A C variable is an entity whose value may vary during
program execution
 It has a name and type associated with it
 Variable name specifies programmer given name to
the memory area allocated to a variable
 Variable type specifies the type of values a variable
can contain
 Example: In i = i + 5, i is a variable

Ref. Page 445 Chapter 21: Introduction to C Programming Languages Slide 11/76
Computer Fundamentals : Pradeep K. Sinha & Priti Sinha

Rules for Constructing Variable Names

 Can have 1 to 31 characters


 Only alphabets, digits, and underscore (as in last_name)
characters are allowed
 Names are case sensitive (nNum and nNUM are different)
 First character must be an alphabet
 Underscore is the only special character allowed
 Keywords cannot be used as variable names
 Examples are: I saving_2007 ArrSum

Ref. Page 445 Chapter 21: Introduction to C Programming Languages Slide 12/76
Computer Fundamentals : Pradeep K. Sinha & Priti Sinha
Data Types Used for Variable Type
Declaration

Data Minimum Storage


Used for Variables that can contain
Type Allocated

int 2 bytes (16 bits) integer constants in the range


-32768 to 32767
short 2 bytes (16 bits) integer constants in the range
-32768 to 32767
long 4 bytes (32 bits) integer constants in the range
-2147483648 to 2147483647
float 4 bytes (32 bits) real constants with minimum 6 decimal digits
precision
double 8 bytes (64 bits) real constants with minimum 10 decimal
digits precision
char 1 byte (8 bits) character constants
enum 2 bytes (16 bits) Values in the range -32768 to 32767
void No storage allocated No value assigned

Ref. Page 446 Chapter 21: Introduction to C Programming Languages Slide 13/76
Computer Fundamentals : Pradeep K. Sinha & Priti Sinha

Variable Type Declaration Examples

int count;
short index;
long principle;
float area;
double radius;
char c;

Ref. Page 446 Chapter 21: Introduction to C Programming Languages Slide 14/76
Computer Fundamentals : Pradeep K. Sinha & Priti Sinha

Standard Qualifiers in C

Category Modifier Description

Lifetime auto Temporary variable


register Attempt to store in processor register, fast access
static Permanent, initialized
extern Permanent, initialized but declaration elsewhere

Modifiability const Cannot be modified once created


volatile May be modified by factors outside program

Sign signed + or –
unsigned + only

Size short 16 bits


long 32 bits

Ref. Page 446 Chapter 21: Introduction to C Programming Languages Slide 15/76
Computer Fundamentals : Pradeep K. Sinha & Priti Sinha
Lifetime and Visibility Scopes of
Variables

 Lifetime of all variables (except those declared as static) is


same as that of function or statement block it is declared in
 Lifetime of variables declared in global scope and static is
same as that of the program
 Variable is visible and accessible in the function or
statement block it is declared in
 Global variables are accessible from anywhere in program
 Variable name must be unique in its visibility scope
 Local variable has access precedence over global variable of
same name

Ref. Page 446 Chapter 21: Introduction to C Programming Languages Slide 16/76
Computer Fundamentals : Pradeep K. Sinha & Priti Sinha

Keywords
 Keywords (or reserved words) are predefined words whose
meanings are known to C compiler
 C has 32 keywords
 Keywords cannot be used as variable names

auto double int struct


break else long switch
case enum register typedef
char extern return union
const float short unsigned
continue for signed void
default goto sizeof volatile
do if static while

Ref. Page 447 Chapter 21: Introduction to C Programming Languages Slide 17/76
Computer Fundamentals : Pradeep K. Sinha & Priti Sinha

Comments
 Comments are enclosed within / and  /
 Comments are ignored by the compiler
 Comment can also split over multiple lines
 Example: / This is a comment statement  /

Ref. Page 447 Chapter 21: Introduction to C Programming Languages Slide 18/76
Computer Fundamentals : Pradeep K. Sinha & Priti Sinha

Operators

Chapter 21: Introduction to C Programming Languages Slide 19/76


Computer Fundamentals : Pradeep K. Sinha & Priti Sinha

Operators
 Operators in C are categorized into data access,
arithmetic, logical, bitwise, and miscellaneous
 Associativity defines the order of evaluation when
operators of same precedence appear in an expression
 a = b = c = 15, ‘=’ has R  L associativity
 First c = 15, then b = c, then a = b is evaluated
 Precedence defines the order in which calculations
involving two or more operators is performed
 x + y  z , ‘’ is performed before ‘+’

Ref. Page 448 Chapter 21: Introduction to C Programming Languages Slide 20/76
Computer Fundamentals : Pradeep K. Sinha & Priti Sinha

Arithmetic Operators
Operator Meaning with Example Associativity Precedence

Arithmetic Operators
+ Addition; x+y LR 4
- Subtraction; x-y LR 4
 Multiplication; xy LR 3
/ Division; x/y LR 3
% Remainder (or Modulus); x%y LR 3

++ Increment;
x++ means post-increment (increment LR 1
the value of x by 1 after using its value);

++x means pre-increment (increment the RL 2


value of x by 1 before using its value)

Ref. Page 448 Chapter 21: Introduction to C Programming Languages Slide 21/76
Computer Fundamentals : Pradeep K. Sinha & Priti Sinha

Arithmetic Operators
Associativit
Operator Meaning with Example Precedence
y
Arithmetic Operators
-- Decrement;
x-- means post-decrement (decrement LR 1
the value of x by 1 after using its value);
--x means pre-decrement (decrement RL 2
the value of x by 1 before using its value)

= x = y means assign the value of y to x RL 14


+= x += 5 means x = x + 5 RL 14
-= x -= 5 means x = x - 5 RL 14
= x = 5 means x = x  5 RL 14
/= x /= 5 means x = x / 5 RL 14
%= x %= 5 means x = x % 5 RL 14

Ref. Page 448 Chapter 21: Introduction to C Programming Languages Slide 22/76
Computer Fundamentals : Pradeep K. Sinha & Priti Sinha

Logical Operators
Operator Meaning with Example Associativity Precedence

Logical Operators
! Reverse the logical value of a single variable; RL 2
!x means if the value of x is non-zero, make it
zero; and if it is zero, make it one
> Greater than; x>y LR 6
< Less than; x<y LR 6
>= Greater than or equal to; x >= y LR 6
<= Less than or equal to; x <= y LR 6
== Equal to; x == y LR 7
!= Not equal to; x != y LR 7
&& AND; x && y means both x and y should be LR 11
true (non-zero) for result to be true
|| OR; x || y means either x or y should be true LR 12
(non-zero) for result to be true

z?x:y If z is true (non-zero), then the value returned RL 13


is x, otherwise the value returned is y

Ref. Page 449 Chapter 21: Introduction to C Programming Languages Slide 23/76
Computer Fundamentals : Pradeep K. Sinha & Priti Sinha

Bitwise Operators
Operator Meaning with Example Associativity Precedence
Bitwise Operators
~ Complement; ~x means RL 2
All 1s are changed to 0s and 0s to 1s
& AND; x & y means x AND y LR 8
| OR; x | y means x OR y LR 10
^ Exclusive OR; x ^ y means x y LR 9

<< Left shift; x << 4 means shift all bits in x LR 5
four places to the left
>> Right shift; x >> 3 means shift all bits LR 5
in x three places to the right
&= x &= y means x = x & y RL 14
|= x |= y means x = x | y RL 14
^= x ^= y means x = x ^ y RL 14
<<= x <<= 4 means shift all bits in x four places RL 14
to the left and assign the result to x
>>= x >>= 3 means shift all bits in x three RL 14
places to the right and assign the result to x

Ref. Page 449 Chapter 21: Introduction to C Programming Languages Slide 24/76
Computer Fundamentals : Pradeep K. Sinha & Priti Sinha

Data Access Operators

Operator Meaning with Example Associativity Precedence

Data Access Operators

x[y] Access yth element of array x; y starts LR 1


from zero and increases monotically up
to one less than declared size of array
x.y Access the member variable y of LR 1
structure x

x –›y Access the member variable y of LR 1


structure x

&x Access the address of variable x RL 2

*x Access the value stored in the storage RL 2


location (address) pointed to by pointer
variable x

Ref. Page 450 Chapter 21: Introduction to C Programming Languages Slide 25/76
Computer Fundamentals : Pradeep K. Sinha & Priti Sinha

Miscellaneous Operators
Associativit Precedenc
Operator Meaning with Example
y e
Miscellaneous Operators

x(y) Evaluates function x with argument y LR 1

sizeof (x) Evaluate the size of variable x in bytes RL 2

sizeof (type) Evaluate the size of data type “type” RL 2


in bytes

(type) x Return the value of x after converting RL 2


it from declared data type of variable
x to the new data type “type”

x,y Sequential operator (x then y) LR 15

Ref. Page 450 Chapter 21: Introduction to C Programming Languages Slide 26/76
Computer Fundamentals : Pradeep K. Sinha & Priti Sinha

Statements

Chapter 21: Introduction to C Programming Languages Slide 27/76


Computer Fundamentals : Pradeep K. Sinha & Priti Sinha

Statements
 C program is a combination of statements written
between { and } braces
 Each statement performs a set of operations
 Null statement, represented by “;” or empty {} braces,
does not perform any operation
 A simple statement is terminated by a semicolon “;”
 Compound statements, called statement block, perform
complex operations combining null, simple, and other
block statements

Ref. Page 450 Chapter 21: Introduction to C Programming Languages Slide 28/76
Computer Fundamentals : Pradeep K. Sinha & Priti Sinha

Examples of Statements

 a = (x + y)  10; / simple statement /

 if (sell > cost) / compound statement follows /


{
profit = sell – cost;
printf (“profit is %d”, profit);
}
else /* null statement follows /
{
}

Ref. Page 450 Chapter 21: Introduction to C Programming Languages Slide 29/76
Computer Fundamentals : Pradeep K. Sinha & Priti Sinha

I/O Operations

Chapter 21: Introduction to C Programming Languages Slide 30/76


Computer Fundamentals : Pradeep K. Sinha & Priti Sinha

Simple I/O Operations

 C has no keywords for I/O operations


 Provides standard library functions for performing all I/O
operations

Ref. Page 451 Chapter 21: Introduction to C Programming Languages Slide 31/76
Computer Fundamentals : Pradeep K. Sinha & Priti Sinha
Basic Library Functions for I/O
Operations
I/O Library
Meanings
Functions
getch() Inputs a single character (most recently typed) from standard input (usually
console).
getche() Inputs a single character from console and echoes (displays) it.
getchar() Inputs a single character from console and echoes it, but requires Enter key to be
typed after the character.
putchar() or Outputs a single character on console (screen).
putch()
scanf() Enables input of formatted data from console (keyboard). Formatted input data
means we can specify the data type expected as input. Format specifiers for
different data types are given in Figure 21.6.
printf() Enables obtaining an output in a form specified by programmer (formatted
output). Format specifiers are given in Figure 21.6. Newline character “\n” is
used in printf() to get the output split over separate lines.
gets() Enables input of a string from keyboard. Spaces are accepted as part of the input
string, and the input string is terminated when Enter key is hit. Note that although
scanf() enables input of a string of characters, it does not accept multi-word
strings (spaces in-between).
puts() Enables output of a multi-word string

Ref. Page 451 Chapter 21: Introduction to C Programming Languages Slide 32/76
Computer Fundamentals : Pradeep K. Sinha & Priti Sinha
Basic Format Specifiers for
scanf() and printf()

Format
Data Types
Specifiers
%d integer (short signed)
%u integer (short unsigned)
%ld integer (long signed)
%lu integer (long unsigned)
%f real (float)
%lf real (double)
%c character
%s string

Ref. Page 452 Chapter 21: Introduction to C Programming Languages Slide 33/76
Computer Fundamentals : Pradeep K. Sinha & Priti Sinha

Formatted I/O Example


/ A portion of C program to illustrate formatted input and output /

int maths, science, english, total;


float percent;

clrscr(); / A C library function to make the screen clear /


printf ( “Maths marks = ” ); / Displays “Maths marks = ” /
scanf ( “%d”, &maths); / Accepts entered value and stores in variable “maths” /
printf ( “\n Science marks = ” ); / Displays “Science marks = ” on next line because of \n /
scanf ( “%d”, &science); / Accepts entered value and stores in variable “science” /
printf ( “\n English marks = ” ); / Displays “English marks = ” on next line because of \n /
scanf ( “%d”, &english); / Accepts entered value and stores in variable “english” /

total = maths + science + english;


percent = total/3; / Calculates percentage and stores in variable “percent” /

printf ( “\n Percentage marks obtained = %f”, percent);


/ Displays “Percentage marks obtained = 85.66” on next line
because of \n /

(Continued on next slide)

Ref. Page 452 Chapter 21: Introduction to C Programming Languages Slide 34/76
Computer Fundamentals : Pradeep K. Sinha & Priti Sinha

Formatted I/O Example


Output:
Maths marks = 92
Science marks = 87
English marks = 78
Percentage marks obtained = 85.66

Ref. Page 452 Chapter 21: Introduction to C Programming Languages Slide 35/76
Computer Fundamentals : Pradeep K. Sinha & Priti Sinha

Preprocessor Directives

Chapter 21: Introduction to C Programming Languages Slide 36/76


Computer Fundamentals : Pradeep K. Sinha & Priti Sinha

Preprocessor Directives
 Preprocessor is a program that prepares a program for
the C compiler
 Examples of some common preprocessor directives in C
are:

Preprocessor
Use
directive
Used to look for a file and place its
#include contents at the location where this
preprocessor directives is used

#define Used for macro expansion


Used for conditional compilation of
#ifdef..#endif
segments of a program

Ref. Page 453 Chapter 21: Introduction to C Programming Languages Slide 37/76
Computer Fundamentals : Pradeep K. Sinha & Priti Sinha

Examples of Preprocessor Directives


#include <stdio.h>
#define PI 3.1415
#define AND &&
#define ADMIT printf (“The candidate can be admitted”);

#ifdef WINDOWS
.
.
.
Code specific to windows operating system
.
.
.
#else
.
.
.
Code specific to Linux operating system
.
.
.
#endif
.
.
.
Code common to both operating systems

Ref. Page 453 Chapter 21: Introduction to C Programming Languages Slide 38/76
Computer Fundamentals : Pradeep K. Sinha & Priti Sinha
Standard Preprocessor
Directives in C
Preprocessor Directive Meaning Category
# Null directive
#error message Prints message when processed
Simple
#line linenum filename Used to update code line number and filename
#pragma name Compiler specific settings
#include filename Includes content of another file File
#define macro/string Define a macro or string substitution
#undef macro Removes a macro definition Macro

#if expr Includes following lines if expr is true


# elif expr Includes following lines if expr is true
#else Handles otherwise conditions of #if
Conditional
#endif Closes #if or #elif block
#ifdef macro Includes following lines if macro is defined
#ifndef imacro Includes following lines if macro is not defined
# String forming operator
## Token pasting operator Operators

defined same as #ifdef

Ref. Page 454 Chapter 21: Introduction to C Programming Languages Slide 39/76
Computer Fundamentals : Pradeep K. Sinha & Priti Sinha

Pointers, Arrays and


Strings

Chapter 21: Introduction to C Programming Languages Slide 40/76


Computer Fundamentals : Pradeep K. Sinha & Priti Sinha

Pointers
 C pointers allow programmers to directly access
memory addresses where variables are stored
 Pointer variable is declared by adding a ‘’ symbol
before the variable name while declaring it.
 If p is a pointer to a variable (e.g. int i, *p = i;)
 Using p means address of the storage location of
the pointed variable
 Using p means value stored in the storage location
of the pointed variable
 Operator ‘&’ is used with a variable to mean variable’s
address, e.g. &i gives address of variable i

Ref. Page 455 Chapter 21: Introduction to C Programming Languages Slide 41/76
Computer Fundamentals : Pradeep K. Sinha & Priti Sinha

Illustrating Pointers Concept

1000 62 i

Location Location Location


address contents name

Address of i = 1000
Value of i = 62

int i = 62;
int p;
int j;
p = &i; / p becomes 1000 /
j = p; / j becomes 62 /
j = 0; / j becomes zero /
j = (&i) / j becomes 62 /

Ref. Page 455 Chapter 21: Introduction to C Programming Languages Slide 42/76
Computer Fundamentals : Pradeep K. Sinha & Priti Sinha

Array
 An array is a collection of fixed number of elements in
which all elements are of the same data type
 It is a homogeneous, linear, and contiguous memory
structure
 Its elements can be referred to by using their subscript
or index position that is monotonic in nature
 First element is always denoted by subscript value of 0
(zero), increasing monotonically up to one less than
declared size of array
 Before using an array, its type and dimension must be
declared
 An array can also be declared as multi-dimensional such
as Matrix2D[10][10]

Ref. Page 456 Chapter 21: Introduction to C Programming Languages Slide 43/76
Computer Fundamentals : Pradeep K. Sinha & Priti Sinha

Illustrating Arrays Concept


1010 92 1005 Y
1008 63 1004 A
1012 10.25
1006 82 1003 B
1008 250.00
1004 66 1002 M
1004 155.50
1002 84 1001 O
1000 82.75
1000 45 1000 B

int marks[6]; float price[4]; char city[6];

Each element Each element Each element


being an int being a float being a char
occupies 2 bytes occupies 4 bytes occupies 1 byte

marks[0] = 45 price[0] = 82.75 city[0] = ‘B’


marks[1] = 84 price[1] = 155.50 city[1] = ‘O’
. . .
. . .
. . .
marks[5] = 92 price[3] = 10.25 city[5] = ‘Y’

(a) An array of (b) An array of (c) An array of


integers having real numbers characters
6 elements having 4 elements having 6 elements

Ref. Page 456 Chapter 21: Introduction to C Programming Languages Slide 44/76
Computer Fundamentals : Pradeep K. Sinha & Priti Sinha

String
 A string is a one-dimensional array of characters
terminated by a null character (‘\0)’
 It is initialized at declaration as
char name[] = “PRADEEP”;
 Its individual elements can be accessed in the same way
as we access array elements such as name[3] = ‘D’
 Strings are used for text processing
 C provides a rich set of string handling library functions

Ref. Page 457 Chapter 21: Introduction to C Programming Languages Slide 45/76
Computer Fundamentals : Pradeep K. Sinha & Priti Sinha

Library Functions for String Handling

Library Function Used To


strlen Obtain the length of a string
strlwr Convert all characters of a string to lowercase
strupr Convert all characters of a string to uppercase
strcat Concatenate (append) one string at the end of another
strncat Concatenate only first n characters of a string at the end of another
strcpy Copy a string into another
strncpy Copy only the first n characters of a string into another
strcmp Compare two strings
strncmp Compare only first n characters of two strings
stricmp Compare two strings without regard to case
strnicmp Compare only first n characters of two strings without regard to case
strdup Duplicate a string
strchr Find first occurrence of a given character in a string
strrchr Find last occurrence of a given character in a string
strstr Find first occurrence of a given string in another string
strset Set all characters of a string to a given character
strnset Set first n characters of a string to a given character
strrev Reverse a string

Ref. Page 458 Chapter 21: Introduction to C Programming Languages Slide 46/76
Computer Fundamentals : Pradeep K. Sinha & Priti Sinha

User Defined Data Types

Chapter 21: Introduction to C Programming Languages Slide 47/76


Computer Fundamentals : Pradeep K. Sinha & Priti Sinha

User Defined Data Types (UDTs)

 UDT is composite data type whose composition is not


included in language specification
 Programmer declares them in a program where they are
used
 Two types of UDTs are:
 Structure
 Union

Ref. Page 457 Chapter 21: Introduction to C Programming Languages Slide 48/76
Computer Fundamentals : Pradeep K. Sinha & Priti Sinha

Structure
 It is a UDT containing a number of data types grouped
together
 Its constituents data types may or may not be of different
types
 It has continuous memory allocation and its minimum size
is the sum of sizes of its constituent data types
 All elements (member variable) of a structure are publicly
accessible
 Each member variable can be accessed using “.” (dot)
operator or pointer (EmpRecord.EmpID or EmpRecord 
EmpID)
 It can have a pointer member variable of its own type,
which is useful in crating linked list and similar data
structures

Ref. Page 457 Chapter 21: Introduction to C Programming Languages Slide 49/76
Computer Fundamentals : Pradeep K. Sinha & Priti Sinha

Structure (Examples)
struct Employee struct Employee
{ {
int EmpID; int EmpID;
char EmpName[20]; char EmpName[20];
}; } EmpRecord;

Struct Employee EmpRecord;


Struct Employee pempRecord = &EmpRecord;

Ref. Page 458 Chapter 21: Introduction to C Programming Languages Slide 50/76
Computer Fundamentals : Pradeep K. Sinha & Priti Sinha

Union
 It is a UDT referring to same memory location using several
data types
 It is a mathematical union of all constituent data types
 Each data member begins at the same memory location
 Minimum size of a union variable is the size of its largest
constituent data types
 Each member variable can be accessed using “,” (dot)
operator
 Section of memory can be treated as a variable of one type
on one occasion, and of another type on another occasion

Ref. Page 459 Chapter 21: Introduction to C Programming Languages Slide 51/76
Computer Fundamentals : Pradeep K. Sinha & Priti Sinha

Union Example

unionNum
{
int intNum;
unsigned
unsNum’
};
union Num Number;

Ref. Page 459 Chapter 21: Introduction to C Programming Languages Slide 52/76
Computer Fundamentals : Pradeep K. Sinha & Priti Sinha
Difference Between Structure and
Union
 Both group a number of data types together
 Structure allocates different memory space contiguously
to different data types in the group
 Union allocates the same memory space to different
data types in the group

Ref. Page 460 Chapter 21: Introduction to C Programming Languages Slide 53/76
Computer Fundamentals : Pradeep K. Sinha & Priti Sinha

Control Structures

Chapter 21: Introduction to C Programming Languages Slide 54/76


Computer Fundamentals : Pradeep K. Sinha & Priti Sinha

Control Structures
 Control structures (branch statements) are decision
points that control the flow of program execution based
on:
 Some condition test (conditional branch)
 Without condition test (unconditional branch)
 They ensure execution of other statement/block or
cause skipping of some statement/block

Ref. Page 460 Chapter 21: Introduction to C Programming Languages Slide 55/76
Computer Fundamentals : Pradeep K. Sinha & Priti Sinha

Conditional Branch Statements

 if is used to implement simple one-way test. It can be in


one of the following forms:
 if..stmt
 if..stmt1..else..stmt2
 if..stmt1..else..if..stmtn
 switch facilitates multi-way condition test and is very
similar to the third if construct when primary test object
remains same across all condition tests

Ref. Page 460 Chapter 21: Introduction to C Programming Languages Slide 56/76
Computer Fundamentals : Pradeep K. Sinha & Priti Sinha

Examples of “if” Construct

 if (i <= 0)  if (i <= 0)
i++; i++;
else if (i >= 0)
j++;
 if (i <= 0) else
i++; k++;
else
j++;

Ref. Page 461 Chapter 21: Introduction to C Programming Languages Slide 57/76
Computer Fundamentals : Pradeep K. Sinha & Priti Sinha

Example of “switch” Construct

switch(ch) Same thing can be written also using if


{ construct as:
case ‘A’:
case ‘B’: if (ch == ‘A’ || ch == ‘B’ || ch == ‘C’)
case ‘C’: printf(“Capital”);
printf(“Capital”); else if (ch == ‘a’ || ch == ‘b’ || ch == ‘c’)
break; printf(“Small”);
case ‘a’: else
case ‘b’: printf(“Not cap or small”);
case ‘c’:
printf(“Small”);
break;
default:
printf(“Not cap or small”);
}

Ref. Page 461 Chapter 21: Introduction to C Programming Languages Slide 58/76
Computer Fundamentals : Pradeep K. Sinha & Priti Sinha

Unconditional Branch Statements


 Break: Causes unconditional exit from for, while, do,
or switch constructs. Control is transferred to
the statement immediately outside the block
in which break appears.
 Continue: Causes unconditional transfer to next
iteration in a for, while, or do construct.
Control is transferred to the statement
beginning the block in which continue
appears.
 Goto label: Causes unconditional transfer to statement
marked with the label within the function.

(Continued on next slide)

Ref. Page 462 Chapter 21: Introduction to C Programming Languages Slide 59/76
Computer Fundamentals : Pradeep K. Sinha & Priti Sinha

Unconditional Branch Statements

 Return [value/variable]: Causes immediate termination of


function in which it appears and
transfers control to the statement
that called the function. Optionally,
it provides a value compatible to
the function’s return data type.

Ref. Page 462 Chapter 21: Introduction to C Programming Languages Slide 60/76
Computer Fundamentals : Pradeep K. Sinha & Priti Sinha

Loop Structures

Chapter 21: Introduction to C Programming Languages Slide 61/76


Computer Fundamentals : Pradeep K. Sinha & Priti Sinha

Loop Structures
 Loop statements are used to repeat the execution of
statement or blocks
 Two types of loop structures are:
 Pretest: Condition is tested before each iteration to
check if loop should occur
 Posttest: Condition is tested after each iteration to
check if loop should continue (at least, a single
iteration occurs)

Ref. Page 462 Chapter 21: Introduction to C Programming Languages Slide 62/76
Computer Fundamentals : Pradeep K. Sinha & Priti Sinha

Pretest Loop Structures


 for: It has three parts:
 Initializer is executed at start of loop
 Loop condition is tested before iteration to
decide whether to continue or terminate the
loop
 Incrementor is executed at the end of each
iteration
 While: It has a loop condition only that is tested
before each iteration to decide whether to
continue or terminate the loop

Ref. Page 462 Chapter 21: Introduction to C Programming Languages Slide 63/76
Computer Fundamentals : Pradeep K. Sinha & Priti Sinha
Examples of “for” and “while”
Constructs

 for (i=0; i < 10; i++)


printf(“i = %d”, i);

 while (i < 10)


{
printf(“i = %d”, i);
i++;
}

Ref. Page 462 Chapter 21: Introduction to C Programming Languages Slide 64/76
Computer Fundamentals : Pradeep K. Sinha & Priti Sinha
Posttest Loop Construct
“do…while”
 It has a loop condition only that is tested after each
iteration to decide whether to continue with next
iteration or terminate the loop
 Example of do…while is:

do {
printf(“i = %d”, i);
i++;
} while (i < 10) ;

Ref. Page 463 Chapter 21: Introduction to C Programming Languages Slide 65/76
Computer Fundamentals : Pradeep K. Sinha & Priti Sinha

Functions

Chapter 21: Introduction to C Programming Languages Slide 66/76


Computer Fundamentals : Pradeep K. Sinha & Priti Sinha

Functions
 Functions (or subprograms) are building blocks of a
program
 All functions must be declared and defined before use
 Function declaration requires function name, argument
list, and return type
 Function definition requires coding the body or logic of
function
 Every C program must have a main function. It is the
entry point of the program

Ref. Page 463 Chapter 21: Introduction to C Programming Languages Slide 67/76
Computer Fundamentals : Pradeep K. Sinha & Priti Sinha

Example of a Function
int myfunc ( int Val, int ModVal )
{
unsigned temp;
temp = Val % ModVal;
return temp;
}

This function can be called from any other place using


simple statement:

int n = myfunc(4, 2);

Ref. Page 464 Chapter 21: Introduction to C Programming Languages Slide 68/76
Computer Fundamentals : Pradeep K. Sinha & Priti Sinha

Sample C Program (Program-1)


/ Program to accept an integer from console and to display
whether the number is even or odd /

# include <stdio.h>
void main()
{
int number, remainder;
clrscr(); / clears the console screen /
printf (“Enter an integer: ”);
scanf (“%d”, &number);
remainder = number % 2;
if (remainder == 0)
printf (“\n The given number is even”);
else
printf (“\n The given number is odd”);

getch();
}

Ref. Page 464 Chapter 21: Introduction to C Programming Languages Slide 69/76
Computer Fundamentals : Pradeep K. Sinha & Priti Sinha

Sample C Program (Program-2)


/ Program to accept an integer in the range 1 to 7 (both inclusive) from
console and to display the corresponding day (Monday for 1, Tuesday for
2, Wednesday for 3, and so on). If the entered number is out of range,
the program displays a message saying that /

# include <stdio.h>
# include <conio.h>

#define MON printf (“\n Entered number is 1 hence day is MONDAY”);


#define TUE printf (“\n Entered number is 2 hence day is TUESDAY”);
#define WED printf (“\n Entered number is 3 hence day is WEDNESDAY”);
#define THU printf (“\n Entered number is 4 hence day is THURSDAY”);
#define FRI printf (“\n Entered number is 5 hence day is FRIDAY”);
#define SAT printf (“\n Entered number is 6 hence day is SATURDAY”);
#define SUN printf (“\n Entered number is 7 hence day is SUNDAY”);
#define OTH printf (“\n Entered number is out of range”);

void main()
{
int day;
clrscr();
printf (“Enter an integer in the range 1 to 7”);
scanf (“%d”, &day);

(Continued on next slide)

Ref. Page 465 Chapter 21: Introduction to C Programming Languages Slide 70/76
Computer Fundamentals : Pradeep K. Sinha & Priti Sinha

Sample C Program (Program-2)


switch(day)
{
Case 1:
MON;
break;
Case 2:
TUE;
break;
Case 3:
WED;
break;
Case 4:
THU;
break;
Case 5:
FRI;
break;
Case 6:
SAT;
break;
Case 7:
SUN;
break;
default:
OTH;
}
getch();
}

Ref. Page 465 Chapter 21: Introduction to C Programming Languages Slide 71/76
Computer Fundamentals : Pradeep K. Sinha & Priti Sinha

Sample C Program (Program-3)


/ Program to accept the radius of a circle from console and to calculate
and display its area and circumference /

# include <stdio.h>
# include <conio.h>
# define PI 3.1415

void main()
{
float radius, area, circum;
clrscr();
printf (“Enter the radius of the circle: ”);
scanf (“%f”, &radius);
area = PI  radius  radius;
circum = 2  PI  radius;
printf (“\n Area and circumference of the circle are %f
and %f respectively”, area, circum);
getch();
}
(Continued on next slide)

Ref. Page 466 Chapter 21: Introduction to C Programming Languages Slide 72/76
Computer Fundamentals : Pradeep K. Sinha & Priti Sinha

Sample C Program (Program-4)


/ Program to accept a string from console and to display the number of
vowels in the string /

# include <stdio.h>
# include <conio.h>
# include <string.h>

void main()
{
char input_string[50]; / maximum 50 characters /
int len;
int i = 0, cnt = 0;
clrscr();
printf (“Enter a string of less than 50 characters: \n”);
gets (input_string);
len = strlen (input_string);
for (i = 0; i < len; i++)
{
switch (input_string[i])

(Continued on next slide)

Ref. Page 466 Chapter 21: Introduction to C Programming Languages Slide 73/76
Computer Fundamentals : Pradeep K. Sinha & Priti Sinha

Sample C Program (Program-4)


{
case ‘a’:
case ‘e’:
case ‘i’:
case ‘o’:
case ‘u’:
case ‘A’:
case ‘E’:
case ‘I’:
case ‘O’:
case ‘U’:
cnt++
}
}
printf (“\n Number of vowels in the string are: %d”, cnt);
getch();
}

Ref. Page 466 Chapter 21: Introduction to C Programming Languages Slide 74/76
Computer Fundamentals : Pradeep K. Sinha & Priti Sinha

Sample C Program (Program-5)


/ Program to illustrate use of a user defined function. The program initializes an array of n elements
from 0 to n-1 and then calculates and prints the sum of the array elements. In this example n = 10 /

#include <stdio.h>
#define SIZE 10

int ArrSum(int *p, int n);


{
int s, tot = 0;
for(s = 0; s < n; s++)
{
tot += *p;
p++;
}
return tot;
}
int main()
{
int i = 0, sum = 0;
int nArr[SIZE] = {0};
while(i < SIZE)
{
nArr[i] = i;
i++
}
sum = ArrSum(nArr, SIZE);
printf("Sum of 0 to 9 = %d\n", sum);
return 0;
}

Ref. Page 467 Chapter 21: Introduction to C Programming Languages Slide 75/76
Computer Fundamentals : Pradeep K. Sinha & Priti Sinha

Key Words/Phrases
 Arithmetic operators  Main function
 Arrays  Member element
 Assignment operators  Null statement
 Bit-level manipulation  Operator associativity
 Bitwise operators  Operator precedence
 Branch statement  Pointer
 Character set  Posttest loop
 Comment statement  Preprocessor directives
 Compound statement  Pretest loop
 Conditional branch  Primitive data types
 Conditional compilation  Reserved words
 Constants  Simple statement
 Control structures  Statement block
 Format specifiers  Strings
 Formatted I/O  Structure data type
 Function  Unconditional branch
 Keywords  Union data type
 Library functions  User-defined data types
 Logical operators  Variable name
 Loop structures  Variable type declaration
 Macro expansion  Variables

Chapter 21: Introduction to C Programming Languages Slide 76/76

You might also like