Introduction To Computers Color

Download as pdf or txt
Download as pdf or txt
You are on page 1of 328

Lecture Notes

Introduction to Computers
1st Computer Science

Prepared by

Prof. Dr. Eng.


Mahmoud E. Gadallah

Revised by
Department of Computer Science
Introduction to Computers Preface

Preface
The students who are going to be specialists in computer science need
to understand the fundamentals and concepts of this subject. The
introduction to computer course aims to achieve this objective. This lecture
notes is prepared to introduce some of the essential topics related to the
computer science to pave the way for students to complete understanding
this field in depth. The topics introduced in this notes are presented in an
introductory form that just open the door for the students to be able to
deeply understand the related courses during their study in computer
science specialization.

In chapter 1, a general idea about the computer system is introduced. The


system unit, as the basic component of a computer, is presented in chapter 2
to explain briefly how the CPU works, and gives students the basic concepts
of the main numbering system which may have applications in computers.
Storage systems are necessary for the computer to perform the function of
data storing. These systems are introduced in chapter 3. In chapter 4, the
Input and output devices are discussed. Chapter 5 describes the system
software as one of the basic components of the computer system. Some
application programs are introduced in chapter 6 and these programs
will be applied practically in the lab related to this course. Chapter 7
outlines the fundamentals of computer networks from both hardware and
software points of views. Chapter 8 and 9 are integrated to introduce the
approaches of problem solving and programs development. In this course,
an introduction to the basics of C++ high-level language is introduced.

B Prof. Dr. Mahmoud E. Gadallah


Introduction to Computers Preface

It should be noted that, these lecture notes are prepared as a handout for
students based mainly on the following reference:

Deborah Morley and Charles S. Parker, “understanding computers,


Today and Tomorrow comprehensive” 13th edition, course technology,
cengage learning, 2011.

However, this reference still necessary for the students to get the full
details and understanding of the topics included in these notes.

The general objectives of this course are to make students understand the
fundamental concepts of computers such as:

1. Computer Systems.
2. The System Unit Processing and Memory.
3. Storage Systems.
4. Input and Output Devices.
5. System Software.
6. Application Software.
7. Computer Networks.
8. Problem Solving and Program Development.
9. Introduction to programming with C++ Language.

Prof. Dr. Mahmoud E. Gadallah C


Introduction to Computers Contents

Contents
Preface--------------------------------------------------------------------B
Chapter 1 : Computer Systems----------------------------- 1

Introduction--------------------------------------------------------------- 2
Architecture Components---------------------------------------------- 3
Hardware Component--------------------------------------------------- 4
Typical Personal Computer System----------------------------------- 5
CPU: Central Processing Unit----------------------------------------- 6
Memory:------------------------------------------------------------------ 7
Types of computer systems--------------------------------------------- 7
1. Supercomputers------------------------------------------------------- 8
2. Mainframes------------------------------------------------------------ 9
3. Minicomputers (midrange servers) -------------------------------10
4. Microcomputer (personal computers)-----------------------------11
5. Portable computers (Mobile devices)-----------------------------12
6. Embedded computers-----------------------------------------------13
Starting the Computer--------------------------------------------------14
Step 1: The BIOS and Setup Program-------------------------------14
Step 2: The Power-On-Self-Test (POST)----------------------------15
Step 3: The Operating System (OS) Loads--------------------------15
Step 4: System Configuration-----------------------------------------16
Step 5: System Utilities Loads----------------------------------------16
Step 6: Users Authentication -----------------------------------------16
Abbreviations-----------------------------------------------------------17
Exercises-----------------------------------------------------------------18
Notes---------------------------------------------------------------------20
Chapter 2 : The System Unit Processing and

Memory--------------------------------------------------------- 26
Introduction -------------------------------------------------------------27
D Prof. Dr. Mahmoud E. Gadallah
Introduction to Computers Contents
Data and Program Representation -----------------------------------29
Digital Data Representation-------------------------------------------29
The Binary Numbering System --------------------------------------30
Numbering Systems----------------------------------------------------31
Why Binary ?------------------------------------------------------------32
Counting and Arithmetic-----------------------------------------------32
Why Octal Number System ?-----------------------------------------33
Why hexadecimal ?-----------------------------------------------------34
Using Positional Notation---------------------------------------------35
Base or Radix-----------------------------------------------------------36
Conversion --------------------------------------------------------------37
Fractions-----------------------------------------------------------------38
Binary Arithmetic-------------------------------------------------------39
Octal Arithmetic--------------------------------------------------------40
Hexadecimal Arithmetic-----------------------------------------------40
Coding Systems for Text-Based Data -------------------------------41
Coding Systems for Other Types of Data ---------------------------41
Machine Language -----------------------------------------------------42
Inside the System Unit ------------------------------------------------42
The Motherboard -------------------------------------------------------43
The CPU ----------------------------------------------------------------43
Processing speed--------------------------------------------------------44
Memory------------------------------------------------------------------45
Fans, Heat Sinks, and Other Cooling Components----------------46
Expansion Slots and Cards--------------------------------------------46
Buses --------------------------------------------------------------------47
Ports ---------------------------------------------------------------------48
How the CPU Works ?-------------------------------------------------49
The System Clock and the Machine Cycle -------------------------50
Making Computers Faster and Better -------------------------------53

Prof. Dr. Mahmoud E. Gadallah E


Introduction to Computers Contents
Now and in the Future-------------------------------------------------53
Improving the Performance of Your System Today----------------53
Strategies for Making Faster and Better Computers---------------53
Pipelining----------------------------------------------------------------54
Future Trends -----------------------------------------------------------55
Exercises-----------------------------------------------------------------57
Notes---------------------------------------------------------------------66
Chapter 3 : Storage Systems------------------------------- 72

Introduction--------------------------------------------------------------73
Storage Systems Characteristics--------------------------------------74
Logical file representation---------------------------------------------76
Physical file representation--------------------------------------------76
Types of storage technology used------------------------------------77
Magnetic Disk Systems------------------------------------------------78
Floppy Disks and Drives----------------------------------------------79
Hard Disk Drives-------------------------------------------------------81
Optical Disc Systems---------------------------------------------------88
Flash Memory Systems------------------------------------------------91
Flash Memory Drives--------------------------------------------------93
Other Types of Storage Systems--------------------------------------93
Storage Systems for Large Computer Systems---------------------98
Comparing Storage Alternatives -------------------------------------99
Exercises--------------------------------------------------------------- 100
Notes------------------------------------------------------------------- 103
Chapter 4 : Input and Output Devices----------------- 109

Introduction------------------------------------------------------------ 110
Input Devices:--------------------------------------------------------- 111
Keyboards------------------------------------------------------------- 111
Can be:----------------------------------------------------------------- 112

F Prof. Dr. Mahmoud E. Gadallah


Introduction to Computers Contents
Pointing Devices------------------------------------------------------ 112
Mouse------------------------------------------------------------------ 113
Electronic Pens-------------------------------------------------------- 114
Touch Screens--------------------------------------------------------- 115
Other Pointing Devices---------------------------------------------- 115
Scanners, Readers, and Digital Cameras-------------------------- 116
Scanners---------------------------------------------------------------- 117
Readers----------------------------------------------------------------- 118
Digital Cameras------------------------------------------------------- 122
Audio Input :---------------------------------------------------------- 124
Output device :-------------------------------------------------------- 125
Display Devices------------------------------------------------------- 125
Display Device Characteristics------------------------------------- 126
Data and Multimedia Projectors------------------------------------ 129
Printers----------------------------------------------------------------- 130
Printer characteristics------------------------------------------------ 130
Multifunction Devices ----------------------------------------------- 134
Exercises--------------------------------------------------------------- 135
Notes------------------------------------------------------------------- 138
Chapter 5 : System Software Operating Systems

and Utility Programs--------------------------------------- 144
Introduction------------------------------------------------------------ 145
System software VS Application software------------------------ 146
The Operating System (OS)----------------------------------------- 147
Functions of an Operating System --------------------------------- 148
Main-Memory Management---------------------------------------- 149
File Management----------------------------------------------------- 149
Secondary-Storage Management----------------------------------- 150
Processing Techniques for Increased Efficiency ----------------- 150
Differences among Operating Systems:--------------------------- 152
Prof. Dr. Mahmoud E. Gadallah G
Introduction to Computers Contents
Operating Systems for Desktop PCs and Servers --------------- 154
Operating Systems for Handheld PCs and Mobile Devices ---- 162
Operating Systems for Larger Computers ------------------------ 163
Utility Programs ------------------------------------------------------ 163
File Management Programs ---------------------------------------- 164
The future of operating systems------------------------------------ 167
Exercises--------------------------------------------------------------- 168
Notes------------------------------------------------------------------- 171
Chapter 6 : Application Software----------------------- 177

Introduction------------------------------------------------------------ 178
Software Ownership Rights----------------------------------------- 179
Installed Software vs. Web-based Software----------------------- 180
Software Suites ------------------------------------------------------- 181
Desktop vs. Mobile Software--------------------------------------- 181
Common Software Commands------------------------------------- 182
Word Processing Concepts------------------------------------------ 184
Spreadsheet Concepts------------------------------------------------ 187
Database Concepts --------------------------------------------------- 191
Presentation Graphics Concepts------------------------------------ 195
Graphics and Multimedia Concepts-------------------------------- 198
Other Types of Application Software------------------------------ 200
Summary--------------------------------------------------------------- 201
Exercises--------------------------------------------------------------- 202
Notes------------------------------------------------------------------- 205
Chapter 7 : Computer Networks-------------------------211

Introduction------------------------------------------------------------ 212
Definition of a network---------------------------------------------- 213
The telecommunications system------------------------------------ 213

H Prof. Dr. Mahmoud E. Gadallah


Introduction to Computers Contents
Analog vs Digital Transmission Terminology-------------------- 214
Analog Data - Digital Signals--------------------------------------- 214
Why Digital?---------------------------------------------------------- 215
Communication Modes --------------------------------------------- 215
Uses for computer networks:---------------------------------------- 216
Networking and Communications Applications------------------ 216
Types of Networks---------------------------------------------------- 219
How Does Data Travel Over a Network?------------------------- 222
Data Transmission Characteristics--------------------------------- 222
Wired vs. Wireless Connections------------------------------------ 223
Communications Protocols ----------------------------------------- 227
Ethernet---------------------------------------------------------------- 227
Token Ring------------------------------------------------------------ 228
Wi-Fi------------------------------------------------------------------- 229
Mesh Networks, WiMAX, Mobile-Fi, and xMax---------------- 229
Bluetooth--------------------------------------------------------------- 230
Ultra Wideband (UWB)---------------------------------------------- 231
TCP/IP and Wireless Application Protocol (WAP)--------------- 231
Phone line and Power line Networks------------------------------ 232
Exercises--------------------------------------------------------------- 236
Notes------------------------------------------------------------------- 239
Chapter 8 : Problem Solving and Program

Development ------------------------------------------------ 245
Introduction ----------------------------------------------------------- 246
The problem----------------------------------------------------------- 247
Problem solving approaches ---------------------------------------- 248
1. The Analytic Approach------------------------------------------- 249
2. The Algorithmic Approach--------------------------------------- 251
A. Sequence structure------------------------------------------------ 253
B. Selection------------------------------------------------------------ 257
Prof. Dr. Mahmoud E. Gadallah I
Introduction to Computers Contents
C. Repetition---------------------------------------------------------- 263
Exercises--------------------------------------------------------------- 267
Notes------------------------------------------------------------------- 270
Chapter 9 : Introduction to programming with

C++ Language----------------------------------------------- 276
Introduction------------------------------------------------------------ 277
The C++ Programming Language --------------------------------- 278
Editing, Compiling and Executing a Simple Program ---------- 278
Indentation------------------------------------------------------------- 284
The development environment and the development cycle ---- 284
Variables and Constants --------------------------------------------- 285
count; ------------------------------------------------------------------ 286
length; ----------------------------------------------------------------- 286
firstInitial;-------------------------------------------------------------- 286
switched_on; ---------------------------------------------------------- 286
Simple Input and Output -------------------------------------------- 296
Control Statements--------------------------------------------------- 298
Exercises--------------------------------------------------------------- 311
Notes------------------------------------------------------------------- 313

J Prof. Dr. Mahmoud E. Gadallah


Introduction to Computers

Chapter 1

Computer Systems

Chapter 1 : Computer Systems

Prof. Dr. Mahmoud E. Gadallah 1


Introduction to Computers Chapter 1 : Computer Systems

Introduction
This chapter introduces a thorough
understanding for what computers
are, how they work, and how
people use them. It gives a brief
Date of lecture

idea about the important terms and


/ / 20

concepts included in this course.


The main components of the
computer and a brief outline for the
hardware and software are introduced.

The general objectives of this chapter:


After completing this chapter, you will be able to do the following:
1. Define a computer and describe its primary operations.
....................................................................................................
Note: ......................................................................................

2. List some important milestones in computer evolution.


3. Identify the major parts of a personal computer, including
input, processing,
and output, storage,
and communications
hardware.
4. Define software and
understand how it is used
to instruct the computer
what to do.
5. List the six basic types of
computers, giving at least one example of each type of computer
and stating what that computer might be used for.

2 Prof. Dr. Mahmoud E. Gadallah


Introduction to Computers Chapter 1 : Computer Systems

Architecture Components
The basic components of a computer system are:
1. Hardware:
• Processes data by executing instructions.
• Provides input and output.

Date of lecture
/ 20
2. Software:
• Instructions executed by the system.

/
3. Data:
• Fundamental representation of facts and observations.
4. Communications:
• Sharing data and processing among different systems.
5. People ware:
• Software engineers, programmers, users, computer
professionals, system analysts, etc.

....................................................................................................
Note: ......................................................................................

Prof. Dr. Mahmoud E. Gadallah 3


Introduction to Computers Chapter 1 : Computer Systems

Hardware Component
The hardware is the physical parts of a computer, i.e., the parts you
can touch. Hardware components can be internal (located inside
the system unit of the computer) or external (located outside the
system unit and connected to the system unit via a wired or wireless
Date of lecture

connection). The main hardware components are:


/ / 20

1. Monitor
2. Motherboard
3. CPU
....................................................................................................
Note: ......................................................................................

4. RAM
5. Expansion cards
6. Power supply
7. Optical disc drive
8. Hard disk drive
9. Keyboard
10. Mouse

4 Prof. Dr. Mahmoud E. Gadallah


Introduction to Computers Chapter 1 : Computer Systems
• Input/output devices:
• Storage Devices:
• CPU:
• ALU: arithmetic logic unit.
• CU: control unit.

Date of lecture
• Interface unit.

/ 20
• Memory:

/
• Short-term storage for CPU
calculations.
• Communication devices:

These components will be explained


throughout this lecture notes.

Typical Personal Computer System

....................................................................................................
Note: ......................................................................................
The following Figure illustrates the basic hardware components of a
personal computer.

1. Scanner 9. Speakers
2. CPU (Microprocessor) 10. Monitor
3. Memory (RAM) 11. System software
4. Expansion cards (graphics cards, etc.) 12. Application software
5. Power supply 13. Keyboard
6. Optical disc drive 14. Mouse
7. Storage (Hard disk or SSD) 15. External hard disk
8. Motherboard 16. Printer

Prof. Dr. Mahmoud E. Gadallah 5


Introduction to Computers Chapter 1 : Computer Systems

CPU: Central Processing Unit


The central Processing unit (CPU)
consists of the following components:
• ALU (arithmetic logic unit):
• Performs arithmetic and
Date of lecture

Boolean logical calculations.


/ / 20

• CU (control unit):
• Controls processing of
instructions.
• Controls movement of data
within the CPU.
• Interface unit: Symbolic representation of an ALU
and its input and output signals
• Moves instructions and data
between the CPU and other hardware components.
• Bus:
....................................................................................................
Note: ......................................................................................

• bundle of wires that carry signals and power between different


components.

Block diagram of a basic uniprocessor-CPU computer. Black


lines indicate data flow, whereas red lines indicate control
flow; arrows indicate flow directions.

6 Prof. Dr. Mahmoud E. Gadallah


Introduction to Computers Chapter 1 : Computer Systems

Memory:
• Also known as primary storage,
working storage, and RAM (random
access memory).
• Consists of bits, each of which hold a

Date of lecture
/ 20
value of either 0 or 1 (8 bits = 1 byte).
• Holds both instructions and data of a

/
computer program (stored program
concept).

Types of computer systems


Computers are classified into six
categories, according to physical size,
processing power, and price.

....................................................................................................
Note: ......................................................................................
• Supercomputers.
• Mainframes.
• Minicomputers (midrange servers).
• Microcomputers (personal computers).
• Mobile devices.
• Embedded computers.

Prof. Dr. Mahmoud E. Gadallah 7


Introduction to Computers Chapter 1 : Computer Systems

1. Supercomputers
• Size:
Supercomputers are the most powerful and most expensive type
of computer.
• Used for:
Date of lecture

The applications that require extraordinary speed, and processing


/ / 20

capabilities such as, controlling missile guidance systems and


satellites, forecasting the weather, exploring for oil, and assisting
with some kind of scientific research.
• Operated by:
They are operated by specialists.
• Cost:
It costs several million dollars.
• Accommodation:
Occupies about 5200 square feet.
....................................................................................................
Note: ......................................................................................

8 Prof. Dr. Mahmoud E. Gadallah


Introduction to Computers Chapter 1 : Computer Systems

2. Mainframes
• Size:
Mainframe computers are large machines that carry out different
tasks for several people at the same time.
• Used for:

Date of lecture
/ 20
Mainframe computers execute millions of instructions per second.
Used to process very large volumes of data.

/
• Operated by:
They are operated by specialists so that ordinary users have only
limited access to them.
• Cost:
They are very expensive, costing £100,000 upwards.
• Accommodation:
They are accommodated in specific rooms designed for the
mainframe.

....................................................................................................
Note: ......................................................................................
• Users:
insurance companies, banks, airlines.

Prof. Dr. Mahmoud E. Gadallah 9


Introduction to Computers Chapter 1 : Computer Systems

3. Minicomputers (midrange servers)


• Size:
A desk-sized computer.
• Used for:
doing powerful jobs once only done by mainframes.
Date of lecture

• Operated by:
/ / 20

personnel specifically trained in an application.


• Cost:
Costs less than a mainframe but is powerful enough to do many
jobs which only mainframes could do in the past.
• Accommodated:
In an office environment.
• Users:
medium-sized organizations or departments of large companies.
....................................................................................................
Note: ......................................................................................

10 Prof. Dr. Mahmoud E. Gadallah


Introduction to Computers Chapter 1 : Computer Systems

4. Microcomputer (personal computers)


• Size:
A small computer with a central processing unit based on a
microprocessor.
• Used for:

Date of lecture
/ 20
The least powerful but most widely used type of computer. It can
be designed to be used on a desk-top or carried.

/
• Operated by:
anyone requiring modest computing facilities.
• Cost:
Cheap.
• Accommodated:
Usually found in a home.
• Users:
Depends on the type of task.

....................................................................................................
Note: ......................................................................................

Prof. Dr. Mahmoud E. Gadallah 11


Introduction to Computers Chapter 1 : Computer Systems

5. Portable computers (Mobile devices)


• Size:
they are the computers that are designed to be carried around
easily (in a briefcase or pocket) depending on their size.
• Used for:
Date of lecture

students, individuals buying a new home computer, and many


/ / 20

business.
• Operated by:
individuals.
• Cost:
Cheapest type of computer.
• Accommodated:
Usually found with individuals.
• Users:
Depends on the type of task.
....................................................................................................
Note: ......................................................................................

There are many types related to the portable computers such as:
notebook or laptop computers, tablet computers, netbooks (mini-
notebooks), ultra-mobile PCs (UMPCs) or handheld computers.

12 Prof. Dr. Mahmoud E. Gadallah


Introduction to Computers Chapter 1 : Computer Systems

6. Embedded computers
It is a tiny computer embedded into a product designed to perform
specific tasks or functions for that product. For example; the
embedded computers in the household appliances such as dishwashers,
microwaves, ovens, coffee makers,… as well as into other objects

Date of lecture
/ 20
such as answering machines, DVD players and televisions. Cars also
use many embedded computers.

/
....................................................................................................
Note: ......................................................................................

Prof. Dr. Mahmoud E. Gadallah 13


Introduction to Computers Chapter 1 : Computer Systems

Starting the Computer


The step-by-step booting process:
1. The BIOS (basic input/output system) and setup program.
2. The power-on-self-test (POST).
3. The operating system loads.
Date of lecture

4. System configuration.
/ / 20

5. System utilities loads.


6. Users Authenticated.
....................................................................................................
Note: ......................................................................................

Step 1: The BIOS and Setup Program


• ROM (read only memory): Permanent and unchanging memory.
• BIOS (basic input/output system): The part of the system software
that includes the instructions that the computer uses to accept input
and output.
• Load: To transfer from a storage device to
memory
• ROM loads BIOS into the computer’s memory.
• Setup program: A special program containing
settings that control the
computer’s hardware.
• The program can be
accessed while the BIOS
information is visible.

14 Prof. Dr. Mahmoud E. Gadallah


Introduction to Computers Chapter 1 : Computer Systems

Step 2: The Power-On-Self-Test (POST)


• POST (power-on-self-test): A series of tests conducted on the
computer’s main memory (random access memory or RAM), input/
output devices, disk drives, and the hard disk.
• BIOS conduct a Power-On-Self-Test (POST): to check the input/

Date of lecture
/ 20
output system for operability.
• The computer: will produce a beeping sound and an error message

/
will appear on the monitor if any problems are encountered.

....................................................................................................
Note: ......................................................................................
Step 3: The Operating System (OS) Loads
• BIOS: searches for the OS.
• Settings in the CMOS
(complementary metal oxide
semiconductor): determine where
to look for the OS.
• The operating system’s kernel: is
loaded into the computer’s memory.
• The OS: takes control of the
computer and begins loading
system configuration information.

Prof. Dr. Mahmoud E. Gadallah 15


Introduction to Computers Chapter 1 : Computer Systems

Step 4: System Configuration


• Registry: A database that stores information about peripherals and
software.
• Peripheral: Device connected to a computer.
• Driver: A utility program
Date of lecture

that makes peripheral devices


/ / 20

function properly.
• The system: is configured from
the operating system’s registry.
• Drivers: are loaded into
memory.

Step 5: System Utilities Loads


• System utilities are loaded into
memory.
....................................................................................................
Note: ......................................................................................

• Volume control.
• Antivirus software.
• PC card unplugging utility.

Step 6: Users Authentication


• Authentication or user login occurs.
• User name
• Password
• The user interface starts, enabling
user interaction with computer
programs.

16 Prof. Dr. Mahmoud E. Gadallah


Introduction to Computers Chapter 1 : Computer Systems

Abbreviations

Abbreviation Definition

Date of lecture
CPU Central Processing Unit

/ 20
ALU Arithmetic Logic Unit

/
CU Control Unit

RAM Random Access Memory

UMPCs Ultra Mobile PCs

BIOS Basic Input/Output System

POST Power On Self Test

ROM Read Only Memory

....................................................................................................
Note: ......................................................................................
OS Operating System

CMOS Complementary Metal Oxide Semiconductor

Prof. Dr. Mahmoud E. Gadallah 17


Introduction to Computers Chapter 1 : Computer Systems
/
Date
/ 20

Exercises

18 Prof. Dr. Mahmoud E. Gadallah


Introduction to Computers Chapter 1 : Computer Systems
1- Circle T if the statement is true, F if the statement is false.
a) T F A mouse is one common input device.
b) T F Software includes all the physical equipment in a computer system.
c) T F A computer can run without an operating system if it has good
application software.
d) T F One of the most common types of home computers is the midrange
server.

/ 20
Date
/
2- Write the best answer in the space provided.
a) …...……. is the operation in which data is entered into the computer.
b) Electronic messages sent over the Internet that can be retrieved by the
recipient at his or her convenience are called …………….. .

Prof. Dr. Mahmoud E. Gadallah 19


Introduction to Computers Chapter 1 : Computer Systems
/
Date
/ 20

Notes

20 Prof. Dr. Mahmoud E. Gadallah


Introduction to Computers Chapter 1 : Computer Systems

/ 20
Date
/

Prof. Dr. Mahmoud E. Gadallah 21


Introduction to Computers Chapter 1 : Computer Systems
/
Date
/ 20

22 Prof. Dr. Mahmoud E. Gadallah


Introduction to Computers Chapter 1 : Computer Systems

/ 20
Date
/

Prof. Dr. Mahmoud E. Gadallah 23


Introduction to Computers Chapter 1 : Computer Systems
/
Date
/ 20

24 Prof. Dr. Mahmoud E. Gadallah


Introduction to Computers Chapter 1 : Computer Systems

/ 20
Date
/

Prof. Dr. Mahmoud E. Gadallah 25


Introduction to Computers

Chapter 2

The System Unit


Processing and Memory
Chapter 2 : The System Unit Processing and Memory

26 Prof. Dr. Mahmoud E. Gadallah


Introduction to Computers Chapter 2 : The System Unit

Introduction
The system unit of the computer is sometimes thought of as the
black box of the computers with respect to the users. This chapter
introduces the following topics:
• How computers represent data and programs.

Date of lecture
/ 20
• How the CPU, memory, and other components are arranged inside

/
the system unit.
• How the CPU works.
• Strategies to speed up a computer today and create faster computers
in the future.

....................................................................................................
Note: ......................................................................................

Prof. Dr. Mahmoud E. Gadallah 27


Introduction to Computers Chapter 2 : The System Unit

The general objectives of this chapter are:


After completing this chapter, you will be able to do the following:
1. Understand how data and programs are represented to a computer
and be able to identify a few of the coding systems used to
accomplish this.
Date of lecture

2. Explain the functions of the hardware components commonly


/ / 20

found inside the system unit, such as the CPU, memory, buses, and
expansion cards.
3. Describe how peripheral devices or other hardware can be added to
a computer.
4. Understand how a computer’s CPU and memory components
process program instructions and data.
5. Name and evaluate several strategies that can be used today for
speeding up the operations of a computer.
6. List some processing technologies that may be used in future
....................................................................................................
Note: ......................................................................................

computers.

28 Prof. Dr. Mahmoud E. Gadallah


Introduction to Computers Chapter 2 : The System Unit

Data and Program Representation


• In order to be understood by a computer, data and programs need
to be represented appropriately.
• Coding systems (or coding
schemes):

Date of lecture
/ 20
Used to represent numeric,

/
text-based, and multimedia data,
as well as to represent programs.

Digital Data Representation


• Digital computers: devices that can only understand two states, off
and on, represented by the digits 0 and 1 (bits, from binary digits)
• Digital data representation: process of representing data in digital
form so it can be used by a computer
Computers represent programs and data through a variety of

....................................................................................................
Note: ......................................................................................
binary-based coding schemes
Bit = a single 1 or 0
Byte = 8 bits
Byte terminology used to express
the size of documents and other
files, programs, etc.
Prefixes are often used to express larger quantities of bytes:
kilobyte (KB), megabyte (MB), gigabyte (GB), etc.

Prof. Dr. Mahmoud E. Gadallah 29


Introduction to Computers Chapter 2 : The System Unit

The Binary Numbering System


• Computers use the binary numbering system, which represents all
numbers using just two symbols (0 and 1).
• Decimal numbering system: uses 10 symbols (0, 1, 2, 3, 4, 5, 6, 7,
8, and 9).
Date of lecture
/ / 20
....................................................................................................
Note: ......................................................................................

30 Prof. Dr. Mahmoud E. Gadallah


Introduction to Computers Chapter 2 : The System Unit

Numbering Systems
Introduction
The numbering system is a way to represent numbers. People
generally use the decimal number system but computers process data
using the binary numbering system. Another numbering system related

Date of lecture
/ 20
to computer use the hexadecimal numbering system, which can be
used to represent long strings of binary numbers in a manner more

/
understandable to people than the binary numbering system.
In this chapter, binary, decimal, octal and hexadecimal numbering
systems will be discussed. The conversion between these numbering
systems will be also explained. Some mathematical operations of these
numbering systems will be covered.
General objectives of this chapter:
On completing this chapter, you will be able to:
• Explain the different numbering systems.

....................................................................................................
Note: ......................................................................................
• Convert from one numbering system to another.
• Perform mathematical operations on the different numbering
systems.

Prof. Dr. Mahmoud E. Gadallah 31


Introduction to Computers Chapter 2 : The System Unit

Why Binary ?
• Early computer design was decimal.
• Mark I and ENIAC.
• John von Neumann proposed binary data processing (1945).
• Simplified computer design.
Date of lecture

• Used for both instructions and data.


/ / 20

• Natural relationship between


on/off switches and .
calculation using Boolean logic.

Counting and Arithmetic


• Decimal or base 10 number system.
• Origin: counting on the fingers.
• “Digit” from the Latin word digitus meaning “finger”.
• Base: the number of different digits including zero in the number
....................................................................................................
Note: ......................................................................................

system.
Example: Base 10 has 10 digits, 0 through 9.
• Binary or base 2 .
• Bit (binary digit): 2 digits, 0 and 1 .
• Octal or base 8: 8 digits, 0 through 7.
• Hexadecimal or base 16:
16 digits, 0 through F.
Examples: 1010 = A16; 1110 = B16.

32 Prof. Dr. Mahmoud E. Gadallah


Introduction to Computers Chapter 2 : The System Unit

Why Octal Number System ?


The Octal Number System is another type of computer and digital
base number system. The Octal Numbering System is very similar in
principle to the previous hexadecimal numbering system except that
in Octal, a binary number is divided up into groups of only 3 bits, with

Date of lecture
/ 20
each group or set of bits having a distinct value of between 000 (0)
and 111 ( 4+2+1 = 7 ).

/
Octal numbers therefore have a range of just “8” digits, (0, 1, 2, 3, 4,
5, 6, 7) making them a Base-8 numbering system and therefore, q is
equal to “8”.

....................................................................................................
Note: ......................................................................................

Prof. Dr. Mahmoud E. Gadallah 33


Introduction to Computers Chapter 2 : The System Unit

Why hexadecimal ?
Hexadecimal numbering system helps to represent long binary
numbers in a way more understandable to people. Also, modern
computer operating systems and networks present variety of
troubleshooting data in hex format.
Date of lecture
/ / 20
....................................................................................................
Note: ......................................................................................

34 Prof. Dr. Mahmoud E. Gadallah


Introduction to Computers Chapter 2 : The System Unit

Using Positional Notation


1- Binary:
1101 01102 = 21410
1 1 0 1 0 1 1 0
Place

Date of lecture
27 26 25 24 23 22 21 20

/ 20
Value 128 64 32 16 8 4 2 1

/
Evaluate 1 * 128 1 * 64 0 * 32 1 *16 0 * 8 1 * 4 1 * 2 0 * 1

Sum for 128 64 0 16 0 4 2 0


Base 10 128+64+16+4+2=214

2- Decimal “Base 10”:


527 = 5 x 102 + 2 x 101 + 7 x 100
5 2 7

....................................................................................................
Note: ......................................................................................
Place
102 101 100
Value 100 10 1
Evaluate 5 * 100 2 * 10 7 *1
Sum 500 20 7

3- Octal:
6248 = 40410
6 2 4
Place
82 81 80
Value 64 8 1
Evaluate 6 * 64 2*8 4 *1
384 16 4
Sum
384+16+4 = 404

Prof. Dr. Mahmoud E. Gadallah 35


Introduction to Computers Chapter 2 : The System Unit
4- Hexadecimal:
6,70416 = 26,37210
6 7 0 4
Place
163 162 161 160
Value 4,096 256 16 1
Date of lecture
/

Evaluate 6 * 4,096 7 * 256 0 * 16 4*1


/ 20

24,576 1,792 0 4
Sum for
Base 10
24,576 + 1,792 + 4 = 26,372

Base or Radix
• Base:
The number of different symbols required to represent any given
....................................................................................................
Note: ......................................................................................

number.
• The larger the base, the more numerals are required:
Base 10: 0,1, 2,3,4,5,6,7,8,9
Base 2: 0,1
Base 8: 0,1,2, 3,4,5,6,7
Base 16: 0,1,2,3,4,5,6,7,8,9,A,B,C,D,E,F

36 Prof. Dr. Mahmoud E. Gadallah


Introduction to Computers Chapter 2 : The System Unit

Conversion
1- from Base 10 “decimal” to Base 2 “binary”:
15610 = 100111002
Divide. Write the integer answer (quotient) under
the long division symbol, and write the remainder
(0 or 1) to the right of the dividend.

Date of lecture
Since we are dividing by 2, when the dividend is

/ 20
even the binary remainder will be 0, and when the
dividend is odd the binary remainder will be 1

/
Continue to divide until you reach 0. Continue
downwards, dividing each new quotient by two and
writing the remainders to the right of each dividend.
Stop when the quotient is 0.

2- from Base 10 “decimal” to Base 16 “Hexadecimal”:


3910 = 2716

....................................................................................................
Note: ......................................................................................
4386810 = 0AB5C16

Prof. Dr. Mahmoud E. Gadallah 37


Introduction to Computers Chapter 2 : The System Unit

Fractions
1- Consider the decimal fraction (0.2589)10:
2 5 8 9
Place
10-1 10-2 10-3 10-4
Date of lecture

Value 1/10 1/100 1/1000 1/10000


/

Evaluate 2*1/10 2*1/100 2*1/1000 2*1/10000


/ 20

.2 .05 .008 .0009


Sum for
Base 10
.2+.05+.008+.0009 = 0.2589

2- Convert the binary fraction 0.1010112 to decimal 0.67187510:


1 0 1 0 1 1
Place
2-1 2-2 2-3 2-4 2-5 2-6
....................................................................................................
Note: ......................................................................................

Value 1/2 1/4 1/8 1/16 1/32 1/64


Evaluate 1*1/2 0*1/4 1*1/8 0*1/16 1*1/32 1*1/64

.5 .125 0.03125 0.015625


Sum for
Base 10
.5+.125+0.03125+0.015625 = 0.671875

38 Prof. Dr. Mahmoud E. Gadallah


Introduction to Computers Chapter 2 : The System Unit

Binary Arithmetic
1- Addition:
Carries 101100
Augends 10110

Date of lecture
+ 10111

/ 20
101101

/
2- Subtraction:
Borrows 001010
Minuend 1110101
- 1001010
101011

....................................................................................................
Note: ......................................................................................
3- Multiplication:

10110
*
1101
10110
00000
+ 10110
10110
100011110

Prof. Dr. Mahmoud E. Gadallah 39


Introduction to Computers Chapter 2 : The System Unit

Octal Arithmetic
1- Addition:
Carries 111
Augends 5471
Date of lecture

+ 3754
/ / 20

11445

2- Subtraction:
Borrows 6 10 4 10
Minuend 7451
- 5643
1606
....................................................................................................
Note: ......................................................................................

Hexadecimal Arithmetic
1- Addition:
Carries 1011
Augends 5BA9
+ D058
12C58

2- Subtraction:
Borrows 9 10 A 10
Minuend A5B9
- 580D
4DAC

40 Prof. Dr. Mahmoud E. Gadallah


Introduction to Computers Chapter 2 : The System Unit

Coding Systems for Text-Based Data


• ASCII and EBCDIC
ASCII (American Standard Code
for Information Interchange):
coding system traditionally used

Date of lecture
/ 20
with PCs
EBCDIC (Extended Binary-Coded

/
Decimal Interchange Code):
developed by IBM, primarily for
mainframe use.

• Unicode: newer code (32 bits per


character is common); universal
coding standard designed to represent
text-based data written in any

....................................................................................................
Note: ......................................................................................
language

Coding Systems for Other Types of Data


• Graphics data: still images often stored as bitmap, a grid of
hundreds of thousands of dots, called pixels.

• Audio data: to convert analog sound to digital sound, several


thousand samples are taken every second; MP3 compression makes
audio files much smaller.

• Video data: displayed using a


collection of frames; amount of
data can be substantial, but can
be compressed.

Prof. Dr. Mahmoud E. Gadallah 41


Introduction to Computers Chapter 2 : The System Unit

Machine Language
Machine language: binary-based language for representing computer
programs the computer can execute directly.

Early computers required programs to be written in machine language.


Date of lecture

Today’s programs are translated into machine language in order to be


/ / 20

understood by the computer.

Most programmers rely on


language translators to translate
their programs into machine
language for them.

Inside the System Unit


the main case of a computer
....................................................................................................
Note: ......................................................................................

The system unit houses the processing hardware for that computer, as
well as disk drives, memory, the power supply, cooling fans, etc.
The system unit for a desktop PC often looks like a rectangular box

1. Monitor
2. Motherboard
3. CPU
4. RAM
5. Expansion cards
6. Power supply
7. Optical disc drive
8. Hard disk drive
9. Keyboard
10. Mouse

42 Prof. Dr. Mahmoud E. Gadallah


Introduction to Computers Chapter 2 : The System Unit

The Motherboard
• Circuit board: thin board containing chips—very small pieces of
silicon or other semi-conducting material onto which integrated
circuits are embedded—and other electronic components.

Date of lecture
/ 20
• Motherboard or system board: the main circuit board inside the
system unit.

/
• External devices (monitors,
keyboards, mice, printers)
connect to the motherboard by
plugging into a port exposed
through the exterior of the
system unit.

....................................................................................................
Note: ......................................................................................
The CPU
Central processing unit (CPU):
• circuitry and components packaged together on a chip which is
plugged directly into the motherboard.
• CPU does the vast majority of processing for a computer.
• Also called the microprocessor or just the processor.
• Can have multiple cores (dual-core).
• Most CPUs are made by
Intel (Pentium 4, Pentium D,
Pentium M, Celeron, etc.) or
AMD (Athlon 64, Sempron,
Turion 64, etc.
• Servers typically use different
CPUs than desktop PCs.

Prof. Dr. Mahmoud E. Gadallah 43


Introduction to Computers Chapter 2 : The System Unit

Processing speed
The processing speed of the computer depends on the following
factors:
• CPU clock speed: which is measured in megahertz (MHz) or
gigahertz (GHz); higher CPU clock speed = more instructions
Date of lecture

processed per second.


/ / 20

• CPU architecture.
• Memory.
• Word size: the amount of data that a CPU can manipulate at one
time; typically 32 or 64 bits.
• Cache memory: special group of
very fast memory chips located on
or close to the CPU.
▪ Level 1 is fastest, followed by
Level 2.
....................................................................................................
Note: ......................................................................................

▪ More cache memory typically =


faster processing.
• Bus width and bus speed:
• Bus = an electronic path over
which data can travel.
• Bus width = the number of wires in the bus over which data
can travel; bus width and speed determine the throughput of the
bus.

44 Prof. Dr. Mahmoud E. Gadallah


Introduction to Computers Chapter 2 : The System Unit

Memory
RAM (random access memory): temporary memory that the
computer uses.

• Consists of chips connected to a memory module which is

Date of lecture
/ 20
connected to the motherboard as shown in the following Figure.
• Hold data and program instructions while they are needed.

/
• RAM is volatile, its content is lost when the computer is shut off.

Registers: high speed memory built into the CPU; used by the CPU.

ROM (read-only memory): non erasable chips located on the


motherboard into which data or programs have been permanently
stored; retrieved by the computer when needed.

....................................................................................................
Note: ......................................................................................
Flash memory: type of nonvolatile memory that can be erased and
reprogrammed; some is built into a PC, also used in sticks, cards, and
drive for storage

Prof. Dr. Mahmoud E. Gadallah 45


Introduction to Computers Chapter 2 : The System Unit

Fans, Heat Sinks, and Other Cooling Components


• One byproduct of packing an increasing amount of technology in a
smaller system unit is heat, a continuing problem for CPU.
• Virtually all computers today employ
fans, heat sinks (small components
Date of lecture
/

typically made out of aluminum with


/ 20

fins that help to dissipate heat), or


other methods to cool the CPU and
system unit.
• Water cooling systems are also
available.

Expansion Slots and Cards


• Expansion slot: a location on the motherboard into which
....................................................................................................
Note: ......................................................................................

expansion cards are inserted.

• Expansion card: a circuit board that can be inserted into


an expansion slot on a PC’s motherboard to add additional
functionality or to attach a peripheral device; also called add-in
boards, interface cards, and adapter boards.

46 Prof. Dr. Mahmoud E. Gadallah


Introduction to Computers Chapter 2 : The System Unit

Buses
The bus is an electronic path within a computer over which data
travels. It is classified into two types; the system bus and the
expansion bus.
• System bus: the bus that moves data back and forth between the

Date of lecture
/ 20
CPU and memory.
• Expansion buses: the buses that connect the CPU to peripheral

/
(typically input and output) devices.
• Common expansion buses:
▪ PCI and PCI Express (PCIe) Bus: very common.
▪ AGP Bus.
▪ Hyper Transport Bus.
▪ Universal Serial Bus (USB): very common.
▪ FireWire/IEEE 1394 Bus: commonly used with video cameras.
▪ Card Bus: used with portable PCs; expected to be replaced by

....................................................................................................
Note: ......................................................................................
cards that connect via USB or PCIe.

Prof. Dr. Mahmoud E. Gadallah 47


Introduction to Computers Chapter 2 : The System Unit

Ports
• Connector on the exterior of a PC’s system unit to which a device
may be attached.
• Common ports: the following table shows some of the commonly
used ports.
Date of lecture
/ / 20

• Many desktop PCs come with a variety of ports on the front of the
system unit for easy access (USB, FireWire, audio, slots for flash
....................................................................................................
Note: ......................................................................................

memory cards, etc.).


• A hub can connect many devices to a single USB or FireWire port.

48 Prof. Dr. Mahmoud E. Gadallah


Introduction to Computers Chapter 2 : The System Unit

How the CPU Works ?


To understand how the CPU works, we should know the components
of the CPU which is referred to as the micro architecture. The micro
architecture varies from processor to processor. The following Figure
illustrates a simplified example of the principal components that might

Date of lecture
/ 20
be included in a single core of a typical CPU. It should be noted that
there are some components which are not shown here because they are

/
not in all the processors. From these components, the buses to connect
the CPU cores to each other (quick path interconnect, QPI), buses to
connect each core to the CPU’s memory controller and the buses to
connect each core to any cache memory that is shared between the
cores.
In the following Figure, the function of the principal components is
briefly given.

....................................................................................................
Note: ......................................................................................

Inside a CPU core (simplified micro architecture)

Prof. Dr. Mahmoud E. Gadallah 49


Introduction to Computers Chapter 2 : The System Unit

The System Clock and the Machine Cycle


System clock:
Timing mechanism within the computer system that synchronizes
the computer’s operations
• Each signal is a cycle.
Date of lecture
/

• Number of cycles per second = hertz (Hz).


/ 20

• Many PC system clocks run at 200 MHz.


• All devices run at a multiple or fraction of the system clock; for
instance, a CPU clock speed
of 2 GHz means the CPU
clock “ticks” 10 times during
each system clock tick.
• During each CPU clock
tick, one or more pieces of
microcode are processed.
....................................................................................................
Note: ......................................................................................

Machine cycle:
Machine cycle is the series of operations involved in the execution
of a single machine level instruction.
The machine cycle consists of four steps as follows:
• Fetch: the program instruction is fetched.
• Decode: the instructions are decoded so the control unit, ALU,
and FPU can understand them.
• Execute: the instructions are carried out.
• Store: the original data or the result from the ALU or FPU
execution is stored either in the CPU’s registers or in memory,
depending on the instruction.

50 Prof. Dr. Mahmoud E. Gadallah


Introduction to Computers

Prof. Dr. Mahmoud E. Gadallah


showing the action of each step.
The following Figures illustrate the four steps of machine cycle

51
Chapter 2 : The System Unit

Note: ...................................................................................... Date of lecture


.................................................................................................... / / 20
Introduction to Computers Chapter 2 : The System Unit

The following Figure shows the application of the machine cycle to


execute the instruction: 2 + 3 = 5
Date of lecture
/ / 20
....................................................................................................
Note: ......................................................................................

As an example for the machine cycle


To compute 2 + 3 = 5

52 Prof. Dr. Mahmoud E. Gadallah


Introduction to Computers Chapter 2 : The System Unit

Making Computers Faster and Better


Now and in the Future
• Over the years, computer
designers have developed a
number of strategies to achieve

Date of lecture
/ 20
faster, more powerful, and more

/
reliable computing performance.
• Researchers are constantly
working on ways to improve the performance of computers of the
future.
• There are several ways computer users can speed up their
computers today, and a number of technologies being developed by
manufacturers to improve computers both today and in the future.

Improving the Performance of Your System Today

....................................................................................................
Note: ......................................................................................
• Add more memory.
• Perform system maintenance (uninstall programs properly, delete
temporary files, scan for viruses and spyware, etc.).
• Buy a larger or second hard drive.
• Upgrade your Internet connection.
• Upgrade your video card.

Strategies for Making Faster and Better Computers


• Improved architecture (smaller components, faster bus speeds,
multiple CPU cores, etc.).
• Improved materials (new backing materials, flexible circuits, etc.).
• Pipelining: allows multiple instructions to be processed at one time.
• Multiprocessing and parallel processing: use multiple processors to
speed up processing.

Prof. Dr. Mahmoud E. Gadallah 53


Prof. Dr. Mahmoud E. Gadallah
Chapter 2 : The System Unit
Introduction to Computers

Pipelining

54
Date of lecture Note: ......................................................................................
/ / 20 ....................................................................................................
Introduction to Computers Chapter 2 : The System Unit

Future Trends
Nanotechnology:
The science of creating tiny computers
and components (less than 100
nanometers in size).

Date of lecture
/ 20
• Some components today fit this
definition.

/
• In the future, components may be
built by working at the individual
atomic and molecular levels.
• Nanotechnology opens up the door
to many new applications.

Quantum computing:
A technology that applies the principles of quantum physics and

....................................................................................................
Note: ......................................................................................
quantum mechanics to computers.
• Utilizes atoms or nuclei working together as quantum bits (qubits).
• Qubits function simultaneously as the computer’s processor and
memory and can represent more than two states.
• Expected to be used for specialized applications, such as encryption
and code breaking.

Prof. Dr. Mahmoud E. Gadallah 55


Introduction to Computers Chapter 2 : The System Unit
Optical computer:
A computer that uses light, such as from laser beams or infrared
beams, to perform digital computations.
• Opto-electronic computers use both optical and electronic
components.
Date of lecture
/ / 20

3D chips:
....................................................................................................
Note: ......................................................................................

Layer transistors to cut down on the surface area required.

56 Prof. Dr. Mahmoud E. Gadallah


Introduction to Computers Chapter 2 : The System Unit

/ 20
Date
/
Exercises

Prof. Dr. Mahmoud E. Gadallah 57


Introduction to Computers Chapter 2 : The System Unit
1- Match each key term on the left with the definition on the right
that best describes it.

Key term matching Description

1. A processing technique that uses multiple


a. ASCII processors or processing cores simultaneously,
/

usually to process a single job as fast as possible.


Date
/ 20

b. binary numbering 2. A fixed-length, binary coding system used to


represent text-based data for computer processing on
system many types of computers.

c. byte 3. A group of 8 bits.

4. A universal bus used to connect up to 127


d. central processing peripheral devices to a computer without requiring the
unit (CPU) use of additional expansion cards.

5. Chips connected to the motherboard to provide a


e. control unit temporary location for the computer to hold data and
program instructions while they are needed.

6. The chip located on the motherboard of a computer


f. motherboard that performs the processing for a computer.

7. The main circuit board of a computer, located


g. nanotechnology inside the system unit, to which all computer
system components connect.

8. The numbering system that represents all


h. parallel processing numbers using just two symbols (0 and 1).

i. RAM (random 9. The part of the CPU that coordinates its operations.
access memory)

10. The science of creating tiny computers and


j. Universal Serial Bus components by working at the individual atomic and
(USB) molecular levels.

58 Prof. Dr. Mahmoud E. Gadallah


Introduction to Computers Chapter 2 : The System Unit
2- Circle T if the statement is true, F if the statement is false, or write
the best answer in the space provided.
1. T F A storage medium that can hold 256 GB can hold about 256 billion
characters.
2. T F The amount of data that can be transferred over a bus in a given time
period determines the bus’s volatility.

/ 20
Date
3. T F Cache memory is typically built into a CPU.

/
4. T F A bus is a pathway, such as on the motherboard or inside the CPU,
along which bits can be transferred.
5. T F Computers that process data with light are referred to as quantum
computers.

3- Number the following terms from 1 to 9 to indicate their size from


smallest to largest.
a. Petabyte d. Yottabyte g. Zettabyte
b. Kilobyte e. Exabyte h. Terabyte
c. Gigabyte f. Byte i. Megabyte

4- What do each of the following acronyms stand for ?


a. KB c. ROM e. PCIe
b. RAM d. USB f. CPU

Prof. Dr. Mahmoud E. Gadallah 59


Introduction to Computers Chapter 2 : The System Unit
5- Supply the missing words to complete the following statements.
1. The smallest piece of data that can be represented by a computer (a 0 or 1) is
called a(n) ……………… .
2. …………. is an international coding system for text-based data using any
written language.
3. The part of the CPU that performs logical operations and integer arithmetic is
/
Date

the ………………..
/ 20

4. The binary number 1101 is equivalent to the decimal number …………


5. A CPU with four separate processing cores is referred to as a(n) ……….
CPU.
6. A(n) …………… is a connector on the exterior of a computer into which a
peripheral device may be plugged.
7. Multi-core CPUs allow ………….. , in which the CPU is able to work on
multiple jobs at one time.

6- Assume you have a USB mouse, USB keyboard, and USB printer
to connect to a computer, but you have only two USB ports. Explain
one solution to this problem that does not involve buying a new
mouse, keyboard, or printer.

7- If your computer seems sluggish, list two things you could do to


try to speed it up without resorting to purchasing an entirely new
system.

60 Prof. Dr. Mahmoud E. Gadallah


Introduction to Computers Chapter 2 : The System Unit
8- Conversions of Numbering System.
1) Convert from decimal to binary
a. (635)10
b. (1750) 10
c. (419) 10
d. (765) 10

/ 20
Date
e. (2309) 10

/
f. (45) 10
g. (285) 10
h. (217.625) 10
i. (125.5) 10
j. (257.875) 10

2) Convert from decimal numbers to corresponding octal


numbers
a. (110) 10
b. (665) 10
c. (366) 10
d. (5975) 10
e. (4036) 10
f. (6507) 10
g. (3915) 10
h. (385) 10
i. (797) 10
j. (325) 10
k. (1005) 10
l. (125.125) 10
m. (225.625) 10
n. (86.875) 10

Prof. Dr. Mahmoud E. Gadallah 61


Introduction to Computers Chapter 2 : The System Unit
3) Convert from decimal to hexadecimal
a. (275) 10
b. (996) 10
c. (1565) 10
d. (988) 10
e. (2925) 10
/
Date
/ 20

f. (1288) 10
g. (8275) 10
h. (387) 10
i. (719) 10
j. (1050) 10

4) Convert from decimal to Binary, Octal and Hexadecimal


a. (2555)10
b. (45)10

c. (285)10

5) Convert binary numbers to decimal numbers


a. (10110101)2
b. (1101)2
c. (1001110)2
d. (1110011)2
e. (100010)2
f. (1111001)2
g. (1000011)2
h. (110011.11)2
i. (100001.101)2

62 Prof. Dr. Mahmoud E. Gadallah


Introduction to Computers Chapter 2 : The System Unit
6) Convert from binary to corresponding octal
a. (111001110)2
b. (100110101)2
c. (10001011110)2
d. (10101010)2

/ 20
e. (111000101.101)2

Date
/
f. (100000100.010)2

7) Convert from binary to hexadecimal


a. (10101110)2
b. (11001)2
c. (1011000110101111110010)2
d. (110111001)2
e. (11101010)2
f. (100011000010)2
g. (111000111101)2
h. (11110000101)2
i. (10001.0011)2
j. (1000100010.1010)2
k. (1000000101.111)2

8) Convert octal numbers to corresponding binary numbers


a. (567)8
b. (2035)8
c. (12467)8
d. (2536.4)8
e. (727.5)8

Prof. Dr. Mahmoud E. Gadallah 63


Introduction to Computers Chapter 2 : The System Unit
9) Convert octal to corresponding decimal
a. (364)8
b. (1035)8
c. (2167)8
d. (7051)8
/

e. (50007)8
Date
/ 20

f. (4056)8
g. (727)8

10) Convert octal to hexadecimal


a. (565)8
b. (3003)8
c. (20503)8
d. (3045)8
e. (757)8

11) Convert hexadecimal to binary


a. (6AB5)16
b. (4F5D)16
c. (69ABC)16
d. (4053)16

64 Prof. Dr. Mahmoud E. Gadallah


Introduction to Computers Chapter 2 : The System Unit
12) Convert hexadecimal to decimal
a. (1A2)16
b. (A3B1)16
c. (ABCD)16
d. (567A)16

/ 20
e. (3459B)16

Date
/
f. (30C7)16
g. (C00AB)16
h. (3459B)16
i. (AACC5)16
j. (FFFFF)16

13) Convert hexadecimal to octal


a. (FED)16
b. (98CA)16
c. (ABCD25)16
d. (FAB02)16

Prof. Dr. Mahmoud E. Gadallah 65


Introduction to Computers Chapter 2 : The System Unit
/
Date
/ 20

Notes

66 Prof. Dr. Mahmoud E. Gadallah


Introduction to Computers Chapter 2 : The System Unit

/ 20
Date
/

Prof. Dr. Mahmoud E. Gadallah 67


Introduction to Computers Chapter 2 : The System Unit
/
Date
/ 20

68 Prof. Dr. Mahmoud E. Gadallah


Introduction to Computers Chapter 2 : The System Unit

/ 20
Date
/

Prof. Dr. Mahmoud E. Gadallah 69


Introduction to Computers Chapter 2 : The System Unit
/
Date
/ 20

70 Prof. Dr. Mahmoud E. Gadallah


Introduction to Computers Chapter 2 : The System Unit

/ 20
Date
/

Prof. Dr. Mahmoud E. Gadallah 71


Introduction to Computers

Chapter 3

Storage Systems

Chapter 3 : Storage Systems

72 Prof. Dr. Mahmoud E. Gadallah


Introduction to Computers Chapter 3 : Storage Systems

Introduction
This chapter introduces the different types of storage systems that
are used to permanently store the data and programs. Any storage
system consists of two parts; the storage medium and the storage
device (driver). The chapter starts with introducing the common

Date of lecture
/ 20
characteristics of the storage systems. The magnetic disks (floppy
and hard) are discussed first because they are considered the prime

/
systems. Then, the optical disks and some other types of storage
systems are explained. Finally, a comparison between the different
types of storage systems is given.

The general objectives of this chapter are:


After completing this chapter, you will be able to:

• Identify the overall characteristics of storage systems.

....................................................................................................
Note: ......................................................................................
• Explain how magnetic disk systems work.
• Explain how optical disc systems work.
• Describe the flash memory systems and how they are used.
• Discuss some other types of storage systems.
• Compare between storage alternatives.

Prof. Dr. Mahmoud E. Gadallah 73


Introduction to Computers Chapter 3 : Storage Systems

Storage Systems Characteristics


All storage systems have specific characteristics such as:
1. Having a storage medium and a storage device.
2. Portability.
3. Volatility.
Date of lecture

4. How data is accessed and represented.


/ / 20

5. The type of storage technology used.

Storage media and storage devices:



Any storage system consists of two parts; storage medium and
storage device.

Storage medium:

It is the hardware where data is actually stored such as Floppy
disk, CD or DVD, etc. It can be removable or non removable
....................................................................................................
Note: ......................................................................................

from the storage device.

Storage device:

It is the device into which storage medium is inserted to be used
such as Floppy disk drive, CD or DVD drive, etc. Devices are
identified by name or letter and can be internal, external, or
remote.

Volatility:

All storage media are nonvolatile which means that when power
to the device is shut off, data stored on the medium remains. This
is in contrast to most types of memory, which are volatile because
the date on them is removed when the power is shut down.

74 Prof. Dr. Mahmoud E. Gadallah


Introduction to Computers Chapter 3 : Storage Systems
Data Access

There are two basic methods for data access on the different
storage systems; they are random access and sequential access.

• Random access (direct access): data can be retrieved


directly from any location on the storage medium, in any

Date of lecture
/ 20
order.

/
• Sequential access: data can only be retrieved in the order in
which it is physically stored on the medium (tape drive).

....................................................................................................
Note: ......................................................................................

Prof. Dr. Mahmoud E. Gadallah 75


Introduction to Computers Chapter 3 : Storage Systems

Logical file representation


Refers to the user’s view of the way data is stored.
• File: something stored on a storage medium, such as a program,
document, or image.
• Filename: name given to a file by the user.
Date of lecture

• Folder: named place on a storage medium into which files can be


/ / 20

stored.
....................................................................................................
Note: ......................................................................................

Physical file representation


Actual physical way the data is stored on the storage media as viewed
by the computer.

76 Prof. Dr. Mahmoud E. Gadallah


Introduction to Computers Chapter 3 : Storage Systems

Types of storage technology used


Data is stored magnetically or optically on many types of storage
media.
• With magnetic media, such as floppy disks, data is stored
magnetically; the data (0s and 1s) is represented using different

Date of lecture
/ 20
magnetic alignments.
• Optical storage media (such as CDs and DVDs) store data

/
optically using laser beams.
• Another technology for data storage depends on representing
data using electrons such as flash memory storage systems.

....................................................................................................
Note: ......................................................................................

Prof. Dr. Mahmoud E. Gadallah 77


Introduction to Computers Chapter 3 : Storage Systems

Magnetic Disk Systems


• Magnetic disk:
Storage medium that records data using magnetic spots on disks
made of flexible plastic or rigid metal. It is the most widely used
storage medium on today’s computers.
Date of lecture

• There are two common types of magnetic disk systems:


/ / 20

▪ Floppy disks (common removable storage medium in the past;


not widely used today).
▪ Hard disks: (Included on nearly all PCs today.

Data is written to the magnetic disks by read/write heads, which


magnetize particles a certain way on the surface of the disks to
represent that data’s 0s and 1s. The particles retain their magnetic
orientation until the orientation is changed again, so files can be
stored, retrieved, rewritten, and deleted as needed. The following
....................................................................................................
Note: ......................................................................................

Figure illustrates how the data are represented magnetically on the


magnetic disk medium.

78 Prof. Dr. Mahmoud E. Gadallah


Introduction to Computers Chapter 3 : Storage Systems

Floppy Disks and Drives


• Floppy disk: low capacity, removable magnetic disk made of
flexible plastic permanently sealed inside a hard plastic cover.
• Floppy disk drive: storage device that reads from and writes to
floppy disks.

Date of lecture
/ 20
• Sometimes referred to as a legacy drive and not included on all
new PCs today.

/
....................................................................................................
Note: ......................................................................................

Prof. Dr. Mahmoud E. Gadallah 79


Introduction to Computers Chapter 3 : Storage Systems
• Floppy disk characteristics:
• 3½ inches in diameter.
• Holds 1.44 MB of data.
• Disk organized into tracks, sectors, and clusters.
• All files take up at least one cluster of space on the disk.
Date of lecture
/ / 20
....................................................................................................
Note: ......................................................................................

• Using floppy disks:


▪ Must be inserted into a floppy
drive (face up and with the disk
shutter closest to the drive door).
▪ Should not be removed when the
disk is being accessed.
▪ If a disk is not formatted, the user
must format it first before it can
be used.

80 Prof. Dr. Mahmoud E. Gadallah


Introduction to Computers Chapter 3 : Storage Systems

Hard Disk Drives


The hard disk is the primary storage system in most of the personal
computers except those depends on using the network storage devices
such as network computers. There are two types of hard drives:
• The internal hard drive:

Date of lecture
/ 20
They are the hard drives that are
located inside the system unit

/
and they are not designed to be
removed unless they need to be
repaired or replaced.
• The external hard drive:
They are the hard drives that are
connected to the computer via a
USB or and are frequently used for
additional storage, backup, and to

....................................................................................................
Note: ......................................................................................
move data between computers.

Magnetic hard drives and solid-state drives (SSDs):



Traditional hard drives are
magnetic hard drives that
contain magnetic hard disks,
read/ write heads, and an
access mechanism. Data is
written to the magnetic hard
disks by read/write heads by
the same way as explained
earlier in the floppy disks.

Prof. Dr. Mahmoud E. Gadallah 81


Introduction to Computers Chapter 3 : Storage Systems
A new type of hard drive is the
solid-state drive (SSD) that uses
flash memory technology instead
of magnetic technology to store
data. While magnetic hard drives
Date of lecture

are currently less expensive and


/

are currently available in larger


/ 20

capacities than SSD, the use of


SSD is growing rapidly, especially
with portable computers like
notebook and netbook computers.

This is because flash memory technology that SSDs are based on


has the following features:
• They allow for faster operation (nine-fold increase in
performance over conventional magnetic hard drives).
....................................................................................................
Note: ......................................................................................

• They reduce the power consumption (SSDs use at least 50%


less power than magnetic hard drive).
• They have increased shock-resistance because there are no
movable parts.

82 Prof. Dr. Mahmoud E. Gadallah


Introduction to Computers Chapter 3 : Storage Systems
Magnetic Hard Drives:

It is a storage system consisting of one or more metal magnetic
disks permanently sealed with an access mechanism inside its
drive.

Date of lecture
/ / 20
....................................................................................................
Note: ......................................................................................
Magnetic hard drive characteristics:

▪ Stores data magnetically.
▪ One or more disks made out of metal.
▪ Disks are permanently sealed inside the hard drive to avoid
contamination and to enable the disks to spin faster.
▪ Organized into clusters, sectors, tracks, and cylinders (the
collection of tracks located in the same location on a set of hard
disk surfaces).

Prof. Dr. Mahmoud E. Gadallah 83


Introduction to Computers Chapter 3 : Storage Systems
▪ Read/write head doesn’t touch the surface of the disk.
Date of lecture
/ / 20

▪ If the PC is bumped while the hard drive is spinning or a


foreign object gets onto the surface of the disk, a head crash
occurs, which may permanently damage the hard drive.

Hard drive speed:



Disk access time: total time that it takes for a hard drive to read
or write data.
....................................................................................................
Note: ......................................................................................

Consists of seek time, rotational delay, data movement time.

Hard disk cache:



A dedicated part of RAM used to store additional data adjacent to
data retrieved during a disk fetch to improve system performance.

84 Prof. Dr. Mahmoud E. Gadallah


Introduction to Computers Chapter 3 : Storage Systems
Partitioning:

Partitioning enables you to logically divide the physical capacity
of a single drive into separate areas, called partitions or logical
drives. It is Used to:
▪ Install more than one operating system.

Date of lecture
▪ Create a recovery partition.

/ 20
▪ Create a new logical drive for

/
data.
▪ Increase efficiency (smaller
drives can use smaller cluster
sizes).
▪ The cluster size, maximum
drive size, and maximum file
size are determined by the file system being used.

....................................................................................................
Note: ......................................................................................
Hard drive interface standards:

• Determine how drive connects to the PC and other
characteristics.
• Most common, for PCs:
▪ Serial ATA(Advanced Technology Attachment) (SATA)
and serial ATA II (SATA II).
▪ SCSI (Small Computer System Interface)and the newer
serial attached SCSI (SAS).
▪ Fiber Channel.
• Hard drives can also connect via
USB or FireWire.
• Usually are installed inside
system unit but can also be
external and portable.

Prof. Dr. Mahmoud E. Gadallah 85


Introduction to Computers Chapter 3 : Storage Systems
External hard drives:

Connect to an external port on the PC
(typically USB, FireWire, or via a wireless
connection)
▪ The entire drive can be moved from one
Date of lecture

PC to another PC when needed.


/ / 20

▪ Good for backup purposes.

Portable hard drives:



▪ Specifically designed to be carried around and moved from one
PC to another.
The following Figure shows some types of portable hard drives.
....................................................................................................
Note: ......................................................................................

86 Prof. Dr. Mahmoud E. Gadallah


Introduction to Computers Chapter 3 : Storage Systems
Super diskettes:

High-capacity removable storage media, usually proprietary (can
only be used with their respective drives).
▪ Most widely used = Zip disk; holds 100, 250, or 750 MB.

Date of lecture
/ 20
Hard disk cartridges:


/
Removable hard disk so higher capacity, but also proprietary.
• REV disk is one example; holds 35 GB.

....................................................................................................
Note: ......................................................................................

Prof. Dr. Mahmoud E. Gadallah 87


Introduction to Computers Chapter 3 : Storage Systems

Optical Disc Systems


• Optical discs (such as CDs and DVDs)
Store data optically using laser beams instead of magnetically.
• Typically 4½-inch circles, although smaller discs and custom
shapes are also available.
Date of lecture

• Divided into tracks and sectors like magnetic disks but use a
/ / 20

single grooved spiral track.


• Can be read-only, recordable, or rewritable.
• High-capacity
(usually at least
650 MB) .
....................................................................................................
Note: ......................................................................................

• Burning:
Burning is defined as the process of recording data onto an optical
disc.
• Spots on the disc (pits) are used to represent the data’s 1s
and 0s; the unchanged areas on the disc are called lands.
• Pits can be molded into the disc surface or created by
changing the
reflectivity of the disc.
• The transition
between a pit and a
land represents a 1; no
transition represents
a 0.

88 Prof. Dr. Mahmoud E. Gadallah


Introduction to Computers Chapter 3 : Storage Systems
Read-Only Discs: CD-ROM and DVD-ROM Discs:

• Can be read from, but not written to, by the user .
• CD-ROM (compact disc read-only memory) disc.
▪ Usually holds about 650 MB.
• DVD-ROM (digital versatile disc read-only memory) disc.

Date of lecture
▪ Holds 4.7 GB (single-sided); 8.5 GB (double-sided).

/ / 20
Recordable Discs:

CD-R, DVD-R, DVD+R, and DVD+R DL Discs
• Can be written to, but cannot be erased and reused.
• Recordable CDs are typically CD-R discs; recordable DVDs
are either DVD-R discs or DVD+R discs.
• CD-R discs are commonly used for back up, sending large files
to others, and creating custom music CDs.

....................................................................................................
Note: ......................................................................................
• DVD-R/DVD+R discs are used for similar purposes when
more storage space is needed, such as large backups and for
home movies and other video files.
• DVD+R DL discs use two recording layers (8.5 GB capacity).

Prof. Dr. Mahmoud E. Gadallah 89


Introduction to Computers Chapter 3 : Storage Systems
Rewritable Discs:

CD-RW, DVD-RW, DVD+RW, DVD-RAM, and Blue Laser
Discs:
• Can be written to, erased, and overwritten just like magnetic
disks.
Date of lecture

• Most common: CD-RW, DVD-RW, and DVD+RW discs.


/ / 20

• The newest rewritable technology uses blue lasers instead


of infrared (CDs) or red (DVDs) lasers to store data more
compactly (23 GB+).
• To record and erase rewritable optical discs, phase-change
technology is used.
....................................................................................................
Note: ......................................................................................

90 Prof. Dr. Mahmoud E. Gadallah


Introduction to Computers Chapter 3 : Storage Systems

Flash Memory Systems


Flash memory is a chip-based storage medium that represents data
using electrons. It is used in a variety of storage systems, such as the
SSDs and some other storage systems shown in the following Figure.
Flash memory systems use flash memory media. The advantages of

Date of lecture
/ 20
flash memory systems are:
• No moving parts so more resistant to shock and vibration and

/
require less power (solid state)
• Very small and so are very appropriate for use with digital cameras,
digital music players, handheld PCs, notebook computers, smart
phones, etc.

....................................................................................................
Note: ......................................................................................
Flash memory card

A small card containing flash memory chips and metal contacts to
connect the card to the device or reader that it is being used with
the following:
• CompactFlash(CF).
• Secure Digital (SD).
• Secure Digital High Capacity (SDHC).
• Secure Digital Extended Capacity (SDXC).
• MultiMedia Card (MMC).
• xD Picture Card (xD).
• Memory Stick (MS).

Prof. Dr. Mahmoud E. Gadallah 91


Introduction to Computers Chapter 3 : Storage Systems
The following Figure shows some examples of systems that use
Flash memory card.
Date of lecture
/ / 20
....................................................................................................
Note: ......................................................................................

Read by flash memory card reader:




Flash memory cards and a multicard reader

92 Prof. Dr. Mahmoud E. Gadallah


Introduction to Computers Chapter 3 : Storage Systems

Flash Memory Drives


Flash memory drives:

Consist of flash memory media and a reader in a single self-
contained unit.
• Typically portable drives that connect via a USB port.

Date of lecture
/ 20
• Also called USB mini drives, USB flash drives, thumb

/
drives, jump drives, and key drives.

Other Types of Storage Systems

....................................................................................................
Note: ......................................................................................
There are some other types of storage systems used with PCs
and business computers such as remote storage, smart cards and
holographic storage.

Remote storage:

This type refers to systems that use a
storage device which is not directly
connected to the computer. In this
type, the device is accessed through a
local network or through the internet.
The types of remote storage are:
1) Network storage.
2) Online storage or Cloud storage.

Prof. Dr. Mahmoud E. Gadallah 93


Introduction to Computers Chapter 3 : Storage Systems
1- Network storage:
Network storage is accessible through a local network. They
work as the same as local storage systems (the storage devices
and media that are directly attached to the user’s computer). This
type is used in business or home to share files on the computers
Date of lecture

connected to a network. Two common types of network storage


/ / 20

used today; namely, they are Network Attached Storage (NAS)


devices and Storage Area Networks (SANs):
• Network attached storage (NAS): high-performance
storage server individually connected to a network to provide
storage for computers on that network.
• Storage area network (SAN): network of hard drives
or other storage devices that provide storage for another
network of computers.
....................................................................................................
Note: ......................................................................................

Storage systems for large computer systems and networks, cont’d


RAID (redundant arrays of independent disks): storage
method that uses several small hard disks in parallel to do the
job of a larger disk.
• Usually involves recording redundant copies of stored
data.
• Helps to increase fault tolerance.
• Different levels of RAID, use combination of disk striping
and disk mirroring.

94 Prof. Dr. Mahmoud E. Gadallah


Introduction to Computers Chapter 3 : Storage Systems
2- Online storage or Cloud storage:
Online storage is accessed via the Internet and it is used for:
• Backup.
• Transferring files to others or to another PC.
• Sharing files with others (online photo sites, etc.).

Date of lecture
/ 20
Example for online storage applications are Google Docs, Flickr

/
photo sharing service and social networking sites like Facebook.

....................................................................................................
Note: ......................................................................................

Prof. Dr. Mahmoud E. Gadallah 95


Introduction to Computers Chapter 3 : Storage Systems

Smart card:

Credit card-sized piece of plastic that contains some computer
circuitry (processor, memory, and storage).
• Store small amount of data: about 256 KB or less.
• Commonly used to store prepaid amounts of digital cash or
Date of lecture

personal information.
/ / 20

• Smart card readers are built into or attached to a PC,


keyboard, vending machine, or other device.
• Some smart cards store biometric data.
....................................................................................................
Note: ......................................................................................

96 Prof. Dr. Mahmoud E. Gadallah


Introduction to Computers Chapter 3 : Storage Systems
Holographic storage:

They are emerging type of 3D storage technology. Holographic
drives typically connect to a computer via a serial attached SCSI
(SAS) or Fibre channel interface.
• Uses multiple blue laser beams to store data in three

Date of lecture
dimensions.

/ 20
• Potential initial applications for holographic data storage

/
systems include:
▪ High-speed digital libraries.
▪ Image processing for medical, video, and military
purposes.
▪ Any other applications in which data needs to be
stored or retrieved quickly in large quantities but rarely
changed.

....................................................................................................
Note: ......................................................................................
Examples of 3D optical
data storage media. Top
row - Written Call/Recall
media; Mempile media.
Middle row - FMD;
D-Data DMD and drive.
Bottom row - Landauer
media; Microholas
media in action.

Prof. Dr. Mahmoud E. Gadallah 97


Introduction to Computers Chapter 3 : Storage Systems

Storage Systems for Large Computer Systems


Redundant Array of Independent Disks (RAID)

It is a method of storing data on two or more hard drives that
work together. It is used to:
▪ Increase the performance by storing more than one copy of
Date of lecture
/

the data that can help in reconstructing data.


/ 20

▪ Protect the critical data on a storage server.

Two types of RAID are used as shown in the following Figure,


they are striping and mirroring.
....................................................................................................
Note: ......................................................................................

98 Prof. Dr. Mahmoud E. Gadallah


Introduction to Computers Chapter 3 : Storage Systems
Magnetic tape:

They are plastic tape with a magnetizable surface that stores data
as a series of magnetic spots:
▪ Uses: primarily for backup and archival purposes
(sequential access only).
▪ Advantage: low cost per megabyte.

Date of lecture
/ 20
▪ Most tapes today are in the form of cartridge tapes.
▪ Read from and written to via a tape drive.

/
....................................................................................................
Note: ......................................................................................
Comparing Storage Alternatives
Factors to consider:
• Speed.
• Compatibility.
• Storage capacity.
• Convenience.
• Portability.
Most users require:
• Hard drive.
• CD or DVD drive.
• Flash memory card reader and USB port for flash memory
drive.

Prof. Dr. Mahmoud E. Gadallah 99


Introduction to Computers Chapter 3 : Storage Systems
/
Date
/ 20

Exercises

100 Prof. Dr. Mahmoud E. Gadallah


Introduction to Computers Chapter 3 : Storage Systems
1- Match each key term on the left with the definition on the right
that best describes it.

Key term matching Description

1- A named place on a storage medium into which


a. disk cache files can be stored to keep the files stored on that me-
dium organized.

/ 20
Date
/
b. file 2- A hard drive that uses flash memory media instead
of metal magnetic hard disks.

3- An emerging type of storage technology that uses


c. flash memory card multiple blue laser beams to store data in three dimen-
sions.
4- A small, rectangular flash memory medium, such
as a Compact Flash (CF) or Secure Digital (SD) card;
d. folder often used with digital cameras and other portable
devices.
5- A storage device designed for large computer sys-
e. hard drive tems and that typically contains multiple high-speed
hard drives.

6- A storage device that is not directly connected


f. holographic storage to the computer being used, such as one accessed
through a local network or the Internet.

7- A storage method that uses several hard drives


g. RAID working together, typically to increase performance
and/or fault-tolerance.

8- Memory used in conjunction with a magnetic hard


h. remote storage drive to improve system performance.

i. solid-state drive 9- Something stored on a storage medium, such as a


(SSD) program, a document, or an image.

10- The primary storage system for most computers;


j. storage server used to store most programs and data used with that
computer.

Prof. Dr. Mahmoud E. Gadallah 101


Introduction to Computers Chapter 3 : Storage Systems
2- Circle T if the statement is true, F if the statement is false, or write
the best answer in the space provided.
a. T F A computer system with a C drive and a D drive must have two
physical hard drives.
b. T F The smallest amount of space a file on a disk can take up is one
cluster.
/
Date

c. T F External hard drives typically connect via a flash memory reader.


/ 20

d. T F A CD-R disc can be written to by the user.


e. T F A hybrid hard drive contains both magnetic hard disks and optical
discs.

3- Write the best answer in the space provided.


a). The drive letter that would most likely be assigned to the primary hard drive
on a typical personal computer is ………..
b). Storage media are not …….. , meaning they do not lose their contents when
the power is shut off.
c). A single-sided, single-layer CD disc typically holds ……… .
d). A(n) ……. looks similar to a credit card but contains a chip and other circuitry
that can store data.
e). Secure Digital (SD) cards are one type of ………. medium.

102 Prof. Dr. Mahmoud E. Gadallah


Introduction to Computers Chapter 3 : Storage Systems

/ 20
Date
/
Notes

Prof. Dr. Mahmoud E. Gadallah 103


Introduction to Computers Chapter 3 : Storage Systems
/
Date
/ 20

104 Prof. Dr. Mahmoud E. Gadallah


Introduction to Computers Chapter 3 : Storage Systems

/ 20
Date
/

Prof. Dr. Mahmoud E. Gadallah 105


Introduction to Computers Chapter 3 : Storage Systems
/
Date
/ 20

106 Prof. Dr. Mahmoud E. Gadallah


Introduction to Computers Chapter 3 : Storage Systems

/ 20
Date
/

Prof. Dr. Mahmoud E. Gadallah 107


Introduction to Computers Chapter 3 : Storage Systems
/
Date
/ 20

108 Prof. Dr. Mahmoud E. Gadallah


Introduction to Computers

Chapter 4

Input and Output Devices

Chapter 4 : Input and Output Devices

Prof. Dr. Mahmoud E. Gadallah 109


Introduction to Computers Chapter 4 : Input and Output Devices

Introduction
This chapter concentrates on the hardware designed for inputting
data into the computer, and then outputting results to the user after
the data has been processed. In this chapter, the most common input
devices used with PCs mainly are discussed. The input devices that
Date of lecture

are discussed in this chapter are the keyboard, pointing devices (such
/ / 20

as a mouse or pen). Next’ the devices that are used to capture data in
electronic form such as scanners, barcode readers, and digital cameras
are explained. Also the input devices for audio data are introduced
The output results are introduced to the user on either the screen or
printed on a paper. This chapter discusses the display devices and
printers as the main output devices. Also, the output devices for audio
output are given.
....................................................................................................
Note: ......................................................................................

The objectives of this chapter are:


After completing this chapter, you will be able to:

• Explain different types of keyboards and pointing devices.


• Describe the functions of scanners, readers, and digital cameras
and explain how they work.
• Understand what audio input is.
• Describe different types of display devices and how they work.
• Explain the main types of printers and how they work.
• Understand what audio output is.

110 Prof. Dr. Mahmoud E. Gadallah


Introduction to Computers Chapter 4 : Input and Output Devices

Input Devices:
Keyboards
• Input device containing keys, arranged in a typewriter type of
configuration, that can be used to input letters, numbers, and other

Date of lecture
symbols.

/ 20
• Most PCs today are designed to be used with a keyboard.

/
• Contains:
▪ Standard alphanumeric keys.
▪ Numeric keypad.
▪ Function keys.
▪ Directional keys and special keys.

....................................................................................................
Note: ......................................................................................

Prof. Dr. Mahmoud E. Gadallah 111


Introduction to Computers Chapter 4 : Input and Output Devices

Can be:
• Wireless .
• Portable.
• Foldable .
• Handheld PCs and mobile devices today often have a built-in
Date of lecture

keyboard or thumb pad (keyboard designed to be pressed with just


/ / 20

the thumbs) .
....................................................................................................
Note: ......................................................................................

Pointing Devices
• Pointing device: input device that moves an onscreen pointer
(arrow or insertion point) to allow the user to select objects on the
screen.
• Usually buttons on the device are used to select objects.
• Common types of pointing devices:
• Mouse.
• Electronic pen.
• Touch screen.

112 Prof. Dr. Mahmoud E. Gadallah


Introduction to Computers Chapter 4 : Input and Output Devices

Mouse
Common pointing device that the user slides along a flat surface
to move a pointer around the screen and clicks its buttons to make
selections.
• Rests on the desk or other flat surface close to the user’s PC.

Date of lecture
/ 20
• Older mechanical mice have a ball exposed on the bottom surface.
• Most mice today are optical mice that track movements with light.

/
• Can be wireless.

....................................................................................................
Note: ......................................................................................

Prof. Dr. Mahmoud E. Gadallah 113


Introduction to Computers Chapter 4 : Input and Output Devices

Electronic Pens
• Electronic pen (stylus or digital pen):
Used instead of a mouse to select objects, as well as to draw or
write electronically on the screen.
• Commonly used with pen-based PCs:
Date of lecture

• To issue commands and input data.


/ / 20

• If handwriting recognition is used, written text can be


converted to editable typed text.

• Also used with:


....................................................................................................
Note: ......................................................................................

• Digital writing systems.


• Graphics tablets.
• Signature capture devices.

114 Prof. Dr. Mahmoud E. Gadallah


Introduction to Computers Chapter 4 : Input and Output Devices

Touch Screens
• Touch screen: display device that is touched with the finger to
issue commands or otherwise generate input to the connected PC.
• Touch screen kiosks are found in retail stores, movie theaters,
courthouses, fast-food restaurants, airports, and point-of-sale (POS)

Date of lecture
/ 20
systems.

/
....................................................................................................
Note: ......................................................................................
Other Pointing Devices
• Joysticks.
• Trackballs.
• Pointing sticks.
• Touch pads.

Prof. Dr. Mahmoud E. Gadallah 115


Introduction to Computers Chapter 4 : Input and Output Devices

Scanners, Readers, and Digital Cameras


• Source documents: documents containing data that already exists
in physical form (order form, photograph, invoice, check, or price
label).
• Source data automation: capturing data directly from a source
Date of lecture

document.
/ / 20

• Most common devices used in source data automation: scanning or


reading devices.
....................................................................................................
Note: ......................................................................................

116 Prof. Dr. Mahmoud E. Gadallah


Introduction to Computers Chapter 4 : Input and Output Devices

Scanners
• Scanner (optical scanner): input device that reads printed text and
graphics and transfers them to a computer in digital form.
• Can scan photos, documents, drawings, etc.
• Data is typically input as a single image.

Date of lecture
/ 20
• If optical character recognition (OCR) is used, text is input as
editable, typed text.

/
• Types of scanners:
• Flatbed.
• Sheetfed.
• Handheld.
• Drum.
• Three-dimensional (3D).
• Quality of scanned images indicated by optical resolution,
measured in number of dots per inch (dpi).

....................................................................................................
Note: ......................................................................................
• Resolution can often be specified.

Prof. Dr. Mahmoud E. Gadallah 117


Introduction to Computers Chapter 4 : Input and Output Devices

Readers
• Barcode readers: input devices that read barcodes.
• Barcode: machine-readable code that represents data as a set of
bars.
• Common types:
Date of lecture

• Universal Product Code (UPC).


/ / 20

• Code 39.
• POSTNET code.
....................................................................................................
Note: ......................................................................................

118 Prof. Dr. Mahmoud E. Gadallah


Introduction to Computers Chapter 4 : Input and Output Devices
Radio frequency identification (RFID) readers:

• Radio frequency identification (RFID): technology used to
store and transmit data located in RFID tags.
• RFID tag: device containing tiny chips and radio antennas
that is attached to objects that will be identified using RFID

Date of lecture
technology.

/ 20
• Applications: tracking inventory pallets and shipping

/
containers, tracking or locating livestock and other animals,
tagging tractors and other large assets to keep track of their
locations.

....................................................................................................
Note: ......................................................................................

Prof. Dr. Mahmoud E. Gadallah 119


Introduction to Computers Chapter 4 : Input and Output Devices
Optical mark readers (OMRs):

Input data from special forms to score or tally exams,
questionnaires, ballots, and so forth.
• Use pencil to fill in small circles/shapes on the form to
indicate their selections.
Date of lecture

• Forms are inserted into an optical mark reader to be scored


/ / 20

or tailed.
....................................................................................................
Note: ......................................................................................

Optical character recognition (OCR) devices:



Read optical characters.
• Optical characters are designed to be identifiable by humans
as well as OCR device.
• Widely used in turnaround documents, such as monthly bills.

120 Prof. Dr. Mahmoud E. Gadallah


Introduction to Computers Chapter 4 : Input and Output Devices
Magnetic ink character recognition (MICR) readers:

Read MICR characters.
• Used primarily for banking
• MICR readers read the special magnetic characters.
• and sort/process.

Date of lecture
• checks.

/ / 20
Biometric readers:

Used to input biometric data.
• Biometric data is based on unique physiological

....................................................................................................
Note: ......................................................................................
characteristics (fingerprint, hand geometry, face, iris of the
eye) or personal traits (voice, signature).
• Readers can be stand-alone or built into another piece of
hardware (keyboard, mouse).
• Also being built into computers and storage devices to allow
access only by authorized individuals.
• Most often used for access control and to verify transactions.

Prof. Dr. Mahmoud E. Gadallah 121


Introduction to Computers Chapter 4 : Input and Output Devices

Digital Cameras
Input device that takes pictures and records them as digital data
(instead of film or videotaped) images.
• Usually designated as:
• Still cameras (take individual still photos).
Date of lecture

• Video cameras (capture moving video images).


/ / 20

Digital still cameras:



• Available in a wide variety of sizes and capabilities.
• Images are immediately available for viewing or printing.
• Typically use flash memory for storage.
• Photos can be transferred to a PC or printer.
• Digital photos can be retouched with image editing software,
posted to a Web page, or burned onto a CD or DVD disc.
• Camera quality is measured in megapixels.
....................................................................................................
Note: ......................................................................................

122 Prof. Dr. Mahmoud E. Gadallah


Introduction to Computers Chapter 4 : Input and Output Devices
Digital video cameras:

Include digital camcorders and small PC video cameras:
• Digital camcorders: similar to analog camcorders, but they
store images on digital media—typically either on mini
digital video (DV) tape cartridges or rewritable DVDs.

Date of lecture
• PC video cameras (PC cams, Web cam): designed to

/ 20
transmit video images over the Internet, such as during a

/
videoconference or video phone call.

....................................................................................................
Note: ......................................................................................

Prof. Dr. Mahmoud E. Gadallah 123


Introduction to Computers Chapter 4 : Input and Output Devices

Audio Input :
Process of entering audio data into the computer (voice and music).
• Voice input systems (speech recognition systems): enable a
computer to recognize the human voice.
▪ Consist of a microphone or headset and appropriate
Date of lecture

software.
/ / 20

▪ Can be used to dictate text or commands into a PC.


• Ocompositions or via a CD or DVD player).
....................................................................................................
Note: ......................................................................................

Speech recognition systems

124 Prof. Dr. Mahmoud E. Gadallah


Introduction to Computers Chapter 4 : Input and Output Devices

Output device :
Display Devices
Output device that presents output visually.
• Soft copy: output that appears on a display device.

Date of lecture
• Monitor: display device for a desktop PC.

/ 20
• Display screen: screen built into the unit of all-in-one PCs,

/
notebook computers, handheld PCs, smart phones, consumer
devices, and many other devices.

....................................................................................................
Note: ......................................................................................

Different display devices

Prof. Dr. Mahmoud E. Gadallah 125


Introduction to Computers Chapter 4 : Input and Output Devices

Display Device Characteristics


• Usually color, but can be monochrome.
• Can be a CRT monitor or a flat-panel display.
• CRT monitor: projects images onto a display screen using
technology similar to that of TVs.
Date of lecture

• Flat-panel display: forms images by manipulating


/ / 20

electronically charged chemicals or gases sandwiched between


thin panes of glass.

CRT vs. Flat-Panel Monitors:



CRT monitors are based on using the cathode ray tube technology
used in conventional TVs. In this technology, an electron gun
sealed inside a large glass tube projects an electron beam at
a screen coated with red, green and blue phosphor dots. This
beam lights up the appropriate colors in each pixel to display the
....................................................................................................
Note: ......................................................................................

necessary image. The CRT is:


• Large.
• Bulky.
• Heavy.
• Consuming high power.
Although CRTs are still in use, most today’s computers use flat-
panel displays. Bothe CRT and flat-panel monitors are shown in
the following illustrative Figure.

126 Prof. Dr. Mahmoud E. Gadallah


Introduction to Computers Chapter 4 : Input and Output Devices
The main features of a display unit are:
• Size (measured diagonally).
• Screen resolution .
• Can be changed.
• Higher resolution = more data on the screen at one

Date of lecture
time.

/ / 20
• Video card (determines display characteristics and how
monitor can connect to the PC).
• Monitors can be also be:
• Wired or wireless.
• 2D or 3D Displays.

....................................................................................................
Note: ......................................................................................
• Digital TV and/or HDTV (High Definition TV) ready or
capable.

Video card

Prof. Dr. Mahmoud E. Gadallah 127


Introduction to Computers Chapter 4 : Input and Output Devices
Flat-Panel Display Technologies:

Flat-panel displays depends form images by using electronically
charged chemicals or gases sandwiched between thin panes of
glass or other transparent material. They need less space and
consume less power than CRTs. Also, they depend on digital
Date of lecture

signals rather than analog signals used by CRT which produces


/ / 20

sharper images.
One disadvantage of flat-panel displays is the displayed images
sometimes cannot be seen clearly when viewed from certain
angles. Among the types of flat-panel displays are:

• Liquid crystal displays (LCDs):


Use charged liquid crystals to display images.
• Organic light emitting diode (OLED) displays:
Use emissive organic material to display brighter and sharper
....................................................................................................
Note: ......................................................................................

images.
▪ Flexible OLEDs (FOLEDs).
▪ Transparent OLEDs (TOLEDs).
▪ Phosphorescent OLEDs (PHOLEDs).
• Plasma displays:
Use layers of gas to display images; most often used on large
displays.

Types of flat-panel displays

128 Prof. Dr. Mahmoud E. Gadallah


Introduction to Computers Chapter 4 : Input and Output Devices

Date of lecture
/ / 20
How OLED displays work

Data and Multimedia Projectors

....................................................................................................
Note: ......................................................................................
• Data projector: display device that projects all computer output to a
wall or projection screen.
• Most data projectors today can project video, in addition to
computer output.
• Can be wireless projectors.

Prof. Dr. Mahmoud E. Gadallah 129


Introduction to Computers Chapter 4 : Input and Output Devices

Printers
Output device that produces output on paper.
• Produce hard copy.
• Can be used with both desktop and portable PCs.
Date of lecture

Printer characteristics
/ / 20

• Impact vs. nonimpact printing.


▪ Most printers are nonimpact.
▪ Impact printers (like dot-matrix printers) are still used for
printing multipart forms and shipping documents.
• Can print in color or black-and white only.
• Can be a personal or network printer.
• Quality is called print resolution and measured in dots per inch
(dpi).
• Print speed is measured in pages per minute (ppm).
....................................................................................................
Note: ......................................................................................

130 Prof. Dr. Mahmoud E. Gadallah


Introduction to Computers Chapter 4 : Input and Output Devices
Laser Printers:

Laser printer is an Output device that uses toner powder and
technology similar to that of a photocopier to produce images on
paper. The following Figure illustrates the steps of printing on
a black-and-white laser printer. The characteristics of the laser

Date of lecture
printer are:

/ / 20
• The standard for business documents.
• Print one entire page at a time.
• Usually black and white, though color printers are available.
• Common print resolution for laser printers is between 600
and 2,400 dpi.

....................................................................................................
Note: ......................................................................................

How black-and-white laser printer work

Prof. Dr. Mahmoud E. Gadallah 131


Introduction to Computers Chapter 4 : Input and Output Devices

Ink-Jet Printers:

Ink-jet printer is an output device that sprays droplets of ink to
produce images on paper as shown in the following Figure. The
main characteristics of the ink-jet printers are:
Date of lecture

• Typically print in color.


/ / 20

• Often the choice for home use.


• Print fairly slowly, one line at a time.
• Quality not quite as good as a laser printer.
....................................................................................................
Note: ......................................................................................

132 Prof. Dr. Mahmoud E. Gadallah


Introduction to Computers Chapter 4 : Input and Output Devices

Special Purpose Printers:



• Photo printers (designed to print photographs).
• Barcode printers (print barcodes; some can encode RFID
tags).
• Label printers (print labels, electronic postage, etc.).

Date of lecture
/ 20
• Portable printers (designed to be carried with you).
• Plotters and wide-format ink-jet printers (print on large

/
paper or other large materials).

....................................................................................................
Note: ......................................................................................

Prof. Dr. Mahmoud E. Gadallah 133


Introduction to Computers Chapter 4 : Input and Output Devices

Multifunction Devices
Audio Output:


• Audio output:
Output in the form of voice or music.
Date of lecture
/ / 20

• Speakers: connect to a PC and provide audio output for


computer games, music, video, TV, videoconferencing, and
other applications that have audio output.

• Voice output systems:


produce spoken output.
....................................................................................................
Note: ......................................................................................

134 Prof. Dr. Mahmoud E. Gadallah


Introduction to Computers Chapter 4 : Input and Output Devices

/ 20
Date
/
Exercises

Prof. Dr. Mahmoud E. Gadallah 135


Introduction to Computers Chapter 4 : Input and Output Devices
1- Match each key term on the left with the definition on the right
that best describes it.

Key term matching Description

1- A common pointing device that the user slides


a. digital camera along a flat surface to move a pointer around the
screen and clicks its buttons to make selections.
/
Date
/ 20

2- A device containing a tiny chip and a radio anten-


b. ink-jet printer na that is attached to an object so it can be identified
using radio frequency identification technology.

3- A display device that is touched with the finger to


c. laser printer issue commands or otherwise provides input to the
connected device.

4- An input device that reads printed text and graphics


d. mouse and transfers them to a computer in digital form.

5- An input device that is used to write electronically


e. OLED display on the display screen.

f. optical character 6- An input device that takes pictures and records


recognition (OCR) them as digital images.

7- An output device that uses toner powder and


g. RFID tag technology similar to that of a photocopier to produce
images on paper.

8- A type of flat-panel display that uses emissive or-


h. scanner ganic material to display brighter and sharper images.

9- An output device that sprays droplets of ink to pro-


i. stylus duce images on paper.

10- The ability of a scanning device to recognize


j. touch screen scanned text characters and converts them to electron-
ic form as text, not images.

136 Prof. Dr. Mahmoud E. Gadallah


Introduction to Computers Chapter 4 : Input and Output Devices
2- Circle T if the statement is true, F if the statement is false.
a). T F A keyboard is an example of a pointing device.
b). T F Most digital still cameras store photos on flash memory media.
c). T F UPC is a type of barcode.
d). T F Consumer kiosks located in retail stores commonly use touch screens
for input.

/ 20
Date
e). T F An ink-jet printer normally produces a better image than a laser

/
printer.

3- Write the best answer in the space provided.


a). With…….. software, pen-based computers can convert handwritten text into
editable, typed text.
b). A(n) ……….. can be used to convert flat printed documents, such as a
drawing or photograph, into digital form.
c). The smallest colorable area in an electronic image (such as a scanned
document, digital photograph, or image displayed on a display screen) is
called a(n) ……………….
d). Portable computers and mobile devices virtually always use …………
displays, while some desktop computers may use the larger, more bulky
………. monitors.

Prof. Dr. Mahmoud E. Gadallah 137


Introduction to Computers Chapter 4 : Input and Output Devices
/
Date
/ 20

Notes

138 Prof. Dr. Mahmoud E. Gadallah


Introduction to Computers Chapter 4 : Input and Output Devices

/ 20
Date
/

Prof. Dr. Mahmoud E. Gadallah 139


Introduction to Computers Chapter 4 : Input and Output Devices
/
Date
/ 20

140 Prof. Dr. Mahmoud E. Gadallah


Introduction to Computers Chapter 4 : Input and Output Devices

/ 20
Date
/

Prof. Dr. Mahmoud E. Gadallah 141


Introduction to Computers Chapter 4 : Input and Output Devices
/
Date
/ 20

142 Prof. Dr. Mahmoud E. Gadallah


Introduction to Computers Chapter 4 : Input and Output Devices

/ 20
Date
/

Prof. Dr. Mahmoud E. Gadallah 143


Introduction to Computers

Chapter 5

System Software
Operating Systems
and Utility Programs

Chapter 5 : System Software Operating Systems and Utility

Programs

144 Prof. Dr. Mahmoud E. Gadallah


Introduction to Computers Chapter 5 : System Software

Introduction
It is well known that all computers require software in order to operate
and perform basic tasks. This chapter focuses on one type of software
that is needed for the computer to translate the user’s command
into a form the computer can understand, to open and close other

Date of lecture
/ 20
programs, to manage the stored files, and to locate and setup new
hardware as it is added to the computer. This type of software is called

/
system software. It should be noted that system software runs in the
background at all times to launch other software when needed and to
make the user able to use the computer.
The chapter starts with a look on the differences between system
software and application software. System software consists of two
types; the operating system (the primary component) and the utility
programs. The functions of operating systems are discussed together
with the differences between them. Then, the chapter explores the

....................................................................................................
Note: ......................................................................................
utility programs which support functions for the operating system such
as allowing to manage files, to perform maintenance on the computer,
to check the computer for viruses, or uninstall a program. Finally, the
chapter introduces a look at what the future operating system may
hold.
The objectives of this chapter:
After completing this chapter, you will be able to:
• Understand the differences between system software and
application software.
• Explain the different functions of an operating systems.
• List the differences between some operating systems.
• Name today’s most widely used operating systems for PCs and
servers.
• Discuss the role of various types of utility programs.
• Describe what the operating systems of the future might be like.

Prof. Dr. Mahmoud E. Gadallah 145


Introduction to Computers Chapter 5 : System Software

System software VS Application software


Generally, software is categorized into two types: system software and
application software. The following is a brief description for the two
types.
• System software:
Date of lecture

System software consists of the operating system and utility


/ / 20

programs that control the computer system and allow the user to
use the computer. The roles of the system software are:
• Enabling the computer to boot.
• Launching application programs.
• Facilitating important jobs such as transferring files from one
storage medium to another.
• Configuring the computer
to work with the hardware
connected to it.
....................................................................................................
Note: ......................................................................................

• Managing files on the hard disk.


• Protecting the computer from
unauthorized use.

• Application software:
Application software includes all the programs that allow the
user to perform specific tasks on the computer. From the task that
can be performed by application
programs are writing a report,
preparing an invoice, viewing a
Web page, listening to a sound
file, playing a game, preparing a
financial statement, designing an
electronic circuit, etc…

146 Prof. Dr. Mahmoud E. Gadallah


Introduction to Computers Chapter 5 : System Software

The Operating System (OS)


Operating system: is a collection of programs that manage and
coordinate the activities taking place within a computer system.

One of the main functions of the OS is

Date of lecture
/ 20
that it interfaces the user with application
programs to facilitate the use of the

/
computer. For example, the following
Figure shows the steps of printing a
document written by a word processing
application program. Here, when the user
issues the print command to the application
program, it hands the document to the
operating system which sends the file to the
printer and runs the printing program.

....................................................................................................
Note: ......................................................................................

The intermediary role of the operating system

Prof. Dr. Mahmoud E. Gadallah 147


Introduction to Computers Chapter 5 : System Software

Functions of an Operating System


• Interfacing with users (typically via a GUI).
• Booting the computer.
• Configuring devices .
• Device drivers are often needed.
Date of lecture

• Plug and Play devices are recognized automatically.


/ / 20

• Managing and monitoring resources and jobs.


• File management.
• Filename rules vary with each operating system.
• File extensions are often added automatically.
• Security .
• Protect access to resources via passwords or other security
procedures.
• Many operating systems include a firewall.
• Security capabilities are often upgraded via security patches.
....................................................................................................
Note: ......................................................................................

Note: refer to the original book for details.

148 Prof. Dr. Mahmoud E. Gadallah


Introduction to Computers Chapter 5 : System Software

Main-Memory Management
• Memory is a large array of words or bytes, each with its own
address. It is a repository of quickly accessible data shared by the
CPU and I/O devices.
• For program to be executed it must be

Date of lecture
/ 20
mapped to absolute addresses and loaded
into memory.

/
• Main memory is a volatile storage device.
It loses its contents in the case of system
failure.
• The operating system is responsible for
the following activities in connections with memory management:
• Keep track of which parts of memory are currently being used
and by whom.
• Decide which processes to load when memory space becomes

....................................................................................................
Note: ......................................................................................
available.
• Allocate and deallocate memory space as needed.

File Management
• A file is a collection of related information defined by its creator.
Commonly, files represent programs (both source and object forms)
and data.
• The operating system is responsible for the following activities in
connections with file management:
• File creation and deletion.
• Directory creation and deletion.
• Support of primitives for manipulating
files and directories.
• File backup on stable (nonvolatile)
storage media.
Prof. Dr. Mahmoud E. Gadallah 149
Introduction to Computers Chapter 5 : System Software

Secondary-Storage Management
• Since main memory (primary storage) is volatile and too small to
accommodate all data and programs permanently, the computer
system must provide secondary storage to back up main memory.
• Most modern computer systems use disks as the principle on-line
Date of lecture

storage medium, for programs and data, most programs are stored
/ / 20

on it until it loaded into memory.


• The operating system is responsible for the
following activities in connection with disk
management:
• Free space management.
• Storage allocation.
• Disk scheduling.
....................................................................................................
Note: ......................................................................................

Processing Techniques for Increased Efficiency


• Multitasking: the ability of an operating system to work with more
than one program (task) at one time.
• CPU rotates between tasks (concurrent processing).

• Multithreading: the ability to run multiple threads for a program


at one time so that processing is completed faster and more
efficiently.
• Thread: sequence of instructions within a program that is
independent of other threads.
• Concurrent processing.

150 Prof. Dr. Mahmoud E. Gadallah


Introduction to Computers Chapter 5 : System Software
• Multiprocessing: multiple processors are used in a single
computer, usually to process multiple jobs at one time faster than
with a single processor.
• Simultaneous processing.
• Used with servers and mainframes; used with desktop PCs now

Date of lecture
(dual-core processors).

/ / 20
• Parallel processing: multiple processors are used in a single
computer, usually to process a single job faster (simultaneous
processing).

• Co processing: utilizing special processors for specialized chores


(e.g. math or graphics coprocessor).

....................................................................................................
Note: ......................................................................................

Sequential vs. simultaneous processing

Prof. Dr. Mahmoud E. Gadallah 151


Introduction to Computers Chapter 5 : System Software
• Memory management: optimizing the use of main memory
(RAM).
• Virtual memory: memory-management technique that uses
hard drive space as additional RAM.
• Buffer: area in RAM or on the hard drive
Date of lecture

designated to hold input and output on


/

their way in or out of the system.


/ 20

• Spooling: placing items in a buffer so


they can be retrieved by the appropriate
device when needed.

Differences among Operating Systems:


....................................................................................................
Note: ......................................................................................

• Command line vs. graphical user interface (GUI).


• Most operating systems use GUI today.

152 Prof. Dr. Mahmoud E. Gadallah


Introduction to Computers Chapter 5 : System Software
• Personal vs. server operating system.
• Personal operating system: designed to be installed on a
single PC.
• Server operating system: designed to be installed on a
network server.

Date of lecture
• Client PCs still use a personal operating system.

/ 20
• Server operating system controls access to network

/
resources.
• Many operating systems come in both versions.

• There are also mobile and embedded operating systems


• Most operating systems are designed for a specific type of
processors (desktop CPUs or server CPUs, for instance).
• Also usually designed for either 32-bit or 64-bit PCs.

....................................................................................................
Note: ......................................................................................

How operating systems are used in a network environment

Prof. Dr. Mahmoud E. Gadallah 153


Introduction to Computers Chapter 5 : System Software

Operating Systems for Desktop PCs and Servers


• Operating systems are usually designed for use on either:
• Desktop PCs (personal operating systems).
• Network servers (network operating systems).
• Many operating systems are available in both personal and server
Date of lecture

versions.
/ / 20

• Older operating system is DOS; most PCs today run Windows,


Mac OS, or Linux.

DOS:

• The operating system designed for and widely used on early
IBM and IBM-compatible PCs .
• There were two primary forms of DOS:
• PC-DOS: created originally for IBM microcomputers.
• MS-DOS: used with IBM-compatible PCs.
....................................................................................................
Note: ......................................................................................

• DOS traditionally used a command-line interface.


• Not widely used today.

DOS Interface (command line)


154 Prof. Dr. Mahmoud E. Gadallah
Introduction to Computers Chapter 5 : System Software

Windows:

the primary PC operating system developed by Microsoft
Corporation.
• Windows 1.0 through Windows 3.x: operating environments
for DOS, not full-fledged operating systems.

Date of lecture
/ 20
• Windows 95 and Windows 98: both used a similar GUI to the
one used with Windows 3.x.

/
• Windows 98 Second Edition (SE): update to Windows 98,
released in 1999; still an installed base of older PCs running
Windows 98 SE.
• Windows NT (New Technology): first 32-bit version of
Windows designed for high-end workstations and servers.
• Windows Me (Millennium Edition): designed for home PCs,
improved home networking and a shared Internet connection.
• Windows 2000: replaced Windows NT; was geared towards

....................................................................................................
Note: ......................................................................................
high-end business workstations and servers, support for
wireless devices.

Prof. Dr. Mahmoud E. Gadallah 155


Introduction to Computers Chapter 5 : System Software
• Windows XP: latest personal version of Windows; designed to
replace both Windows Me and Windows 2000.
• Based on Windows NT technology.
• More stable and powerful than earlier versions of
Windows; built on the Windows 9x kernel.
Date of lecture

• Newest features are related to multimedia and


/

communications.
/ 20

• Available in five versions plus Starter Editions in other


languages.
....................................................................................................
Note: ......................................................................................

• Windows Server 2003: most recent version of Windows


designed for server use.
• Builds on the server version of Windows 2000 but is
designed to be easier to deploy, manage, and use.
• Incorporates Microsoft .NET technology for connecting
information, people, systems, and devices.

• Windows Vista: upcoming version of Windows (known


before as Longhorn) to replace Windows XP.

156 Prof. Dr. Mahmoud E. Gadallah


Introduction to Computers Chapter 5 : System Software
• Windows 7: is a personal
computer operating system
developed by Microsoft.
It is a part of Windows
NT family of operating

Date of lecture
systems. Development

/ 20
of Windows 7 started as

/
early as 2006 under the
codename “Blackcomb.”
Windows 7 was released to manufacturing on July 22, 2009,
and became generally available on October 22, 2009.

• Windows 8: is a personal computer operating system


developed by Microsoft as part of the Windows NT family of
operating systems. Development of Windows 8 started before

....................................................................................................
Note: ......................................................................................
the release of its predecessor, Windows 7, in 2009.

• Windows 8.1: (codenamed Blue) is an upgrade for Windows 8.

Prof. Dr. Mahmoud E. Gadallah 157


Introduction to Computers Chapter 5 : System Software

Mac OS:

proprietary operating system for computers
made by Apple Corporation.

• Based on the UNIX operating system;


Date of lecture

originally set the standard for graphical


/ / 20

user interfaces.

• Mac OS X: most recent version of the operating system used


on Apple computers; latest personal and server versions are
version 10.4, known as Tiger.
....................................................................................................
Note: ......................................................................................

158 Prof. Dr. Mahmoud E. Gadallah


Introduction to Computers Chapter 5 : System Software

UNIX:

operating system developed in the 1970s for midrange servers and
mainframes; many variations of this operating system are in use
today.
• Multi user, multitasking.

Date of lecture
/ 20
• More expensive, requires a higher level of PC knowledge, and
tends to be harder to install, maintain, and upgrade than most

/
other operating systems.
• “UNIX” initially referred to the original UNIX operating
system, now refers to a group of similar operating systems
based on UNIX.

....................................................................................................
Note: ......................................................................................

Prof. Dr. Mahmoud E. Gadallah 159


Introduction to Computers Chapter 5 : System Software

Linux:

version (flavor) of UNIX available without charge over the
Internet.
• Increasingly being used with PCs, servers,
mainframes, and supercomputers.
Date of lecture

• Is open-source software: has been


/ / 20

collaboratively modified by volunteer


programmers all over the world.
• Originally used a command line interface,
most recent versions use a GUI.
• Strong support from mainstream companies, such as Sun, IBM,
HP, and Novell.
• Used on PCs, mainframes, and consumer appliances.
....................................................................................................
Note: ......................................................................................

Windows interface (GUI)

160 Prof. Dr. Mahmoud E. Gadallah


Introduction to Computers Chapter 5 : System Software

NetWare:

widely used operating system for PC-based networks.
• Developed by Novell.
• Competes directly with the server
versions of Windows and Mac OS.

Date of lecture
/ 20
• Provides a shell around the users’ local
desktop operating systems so they can

/
interact with network resources .

Solaris:

UNIX-based operating system developed by Sun Microsystems
for Sun computers.
• Can run on desktop systems and servers,
as well as on some supercomputers.

....................................................................................................
Note: ......................................................................................
• Latest version “Solaris 10” is designed
to run across a variety of platforms in a
safe, efficient, and stable manner.

Prof. Dr. Mahmoud E. Gadallah 161


Introduction to Computers Chapter 5 : System Software

Operating Systems for Handheld PCs and Mobile


Devices
• Embedded and mobile versions of Windows.
• Windows Embedded: family of operating systems based on
Windows, designed for nonpersonal computer devices, such as
Date of lecture
/

cash registers and consumer electronic devices.


/ 20

• Windows Mobile: family of operating systems based on


Windows and designed for handheld PCs, smart phones, and
other mobile devices.
• Palm OS: designed for Palm handheld PCs.
• Embedded Linux: designed for handheld PCs and mobile devices.
• Symbian OS: designed for use with smart phones.
....................................................................................................
Note: ......................................................................................

162 Prof. Dr. Mahmoud E. Gadallah


Introduction to Computers Chapter 5 : System Software

Operating Systems for Larger Computers


• Larger computers sometimes use operating systems designed solely
for that type of system.
• IBM’s z/OS, OS/390, and MVS operating systems are designed for
their various mainframes.

Date of lecture
/ 20
• Windows, UNIX, and Linux, are also used with both mainframes
and supercomputers.

/
• Often a group of Linux PCs are linked together to form what is
referred to as a Linux supercluster supercomputer.

Utility Programs
It is a type of software that performs a specific task, usually related to
managing or maintaining the computer system.
• Many utilities are built into operating systems (for finding files,
viewing images, backing up files, etc.).

....................................................................................................
Note: ......................................................................................
• Utilities are also available as stand-alone products.

Prof. Dr. Mahmoud E. Gadallah 163


Introduction to Computers Chapter 5 : System Software

File Management Programs


• File management programs: utility programs that enable the user
to perform file management tasks, such as:
• Looking at the contents of a PC or storage medium.
• Creating folders.
Date of lecture

• Copying, moving, and renaming files and folders.


/ / 20

• Deleting files and folders.


....................................................................................................
Note: ......................................................................................

164 Prof. Dr. Mahmoud E. Gadallah


Introduction to Computers Chapter 5 : System Software
• Search tools: utility programs designed to search for files on the
user’s hard drive.
• Diagnostic programs: evaluate your system and make
recommendations for fixing any errors found.
• Disk management programs: diagnose and repair problems

Date of lecture
related to your hard drive.

/ 20
• File compression programs: reduce the size of files so they take

/
up less storage space on a storage medium or can be transmitted
faster over the Internet.
• Required to both compress (zip) and decompress (unzip)
files.
• Common programs are WinZip (Windows users) and Stuffit
(Mac users).

....................................................................................................
Note: ......................................................................................

Prof. Dr. Mahmoud E. Gadallah 165


Introduction to Computers Chapter 5 : System Software
• Uninstall utilities: remove programs from your hard drive without
leaving bits and pieces behind.
• Uninstall capabilities are built into most
operating systems.
• Uninstall utility programs are also available as
Date of lecture

stand-alone programs.
/

• Sometimes an uninstall option is included in a


/ 20

program’s folder when that program is originally installed.


• Important to properly uninstall programs, not just delete them.

• Backup and recovery utilities: programs to make the backup and


restoration process easier.
• Backup: a duplicate copy of data or other computer content
• Good backup procedures are critical for
businesses and individuals.
• Backup data can be stored on a CD or DVD,
....................................................................................................
Note: ......................................................................................

second hard drive, flash memory drive, or


uploaded to the Internet
• It is a good idea to backup your entire PC once all programs
have been installed, so your system can be restored to that
configuration. The Windows System Restore program exists for
that purpose.

• Security programs:
• Antivirus programs can protect against getting a virus in
the first place, as well as detect and remove
viruses.
• Antispyware programs can detect and remove
spyware programs installed on your PC.
• Firewalls can protect against someone
accessing your PC via the Internet.
166 Prof. Dr. Mahmoud E. Gadallah
Introduction to Computers Chapter 5 : System Software

The future of operating systems


It is expected that the Oss will continue to become more user friendly
and may be driven primarily by voice, eyes and brain signals. Also,
OSs will continue to be more stable and self healing (repairing) or
restoring system files as needed. In addition, it is expected to continue

Date of lecture
/ 20
to include security and technological improvements.

/
It is expected also that the OSs will enable users to access software
available on the internet or other networks, instead of accessing
software on the local computer.

....................................................................................................
Note: ......................................................................................

Prof. Dr. Mahmoud E. Gadallah 167


Introduction to Computers Chapter 5 : System Software
/
Date
/ 20

Exercises

168 Prof. Dr. Mahmoud E. Gadallah


Introduction to Computers Chapter 5 : System Software
1- Match each key term on the left with the definition on the right
that best describes it.

Key term matching Description

1- A duplicate copy of data or other computer content


a. Android for use in the event that the original version is de-
stroyed.

/ 20
Date
2- A Linux-based operating system designed for mo-

/
b. backup bile phones and developed by a group of companies
that includes Google.

3- A memory-management technique that uses hard


c. device driver drive space as additional RAM.

4- A program that enables an operating system to


d. kernel communicate with a specific hard-ware device.

5- A type of software that performs a specific task,


e. multitasking usually related to managing or maintaining the com-
puter system.

6- The capability of an operating system to run more


f. operating system than one program at one time.

g. spooling 7- The essential portion, or core, of an operating sys-


tem.

8- The main component of system software that


enables the computer to manage its activities and the
h. utility program resources under its control, run application programs,
and interface with the user.

9- The primary personal computer operating system


i. virtual memory developed by Microsoft Corporation.

10- The process of placing items in a buffer so the ap-


j. Windows propriate device (such as a printer) can retrieve them
when needed.

Prof. Dr. Mahmoud E. Gadallah 169


Introduction to Computers Chapter 5 : System Software
2- Circle T if the statement is true, F if the statement is false.
a). T F Windows 7 is an example of an operating system.
b). T F Most operating systems today use a command line interface.
c). T F Mobile devices, such as portable digital media players and mobile
phones, typically require an operating system.
d). T F Windows Explorer is an operating system designed for mobile
/
Date

phones.
/ 20

e). T F Windows Mobile is a versatile operating system designed to be


used on a variety of computer types, such as mainframes, servers, personal
computers, and mobile phones.

3- Write the best answer in the space provided.


a). …………… refers to the ability of an operating system to have more than one
program open at one time.
b). ………. is an operating system that is available for free over the Internet.
c). To decrease the size of a file, a(n) ……….. utility program can be used.
d). To guard against losing your data if a computer problem occurs, you should
…………….. your data files on a regular basis.

170 Prof. Dr. Mahmoud E. Gadallah


Introduction to Computers Chapter 5 : System Software

/ 20
Date
/
Notes

Prof. Dr. Mahmoud E. Gadallah 171


Introduction to Computers Chapter 5 : System Software
/
Date
/ 20

172 Prof. Dr. Mahmoud E. Gadallah


Introduction to Computers Chapter 5 : System Software

/ 20
Date
/

Prof. Dr. Mahmoud E. Gadallah 173


Introduction to Computers Chapter 5 : System Software
/
Date
/ 20

174 Prof. Dr. Mahmoud E. Gadallah


Introduction to Computers Chapter 5 : System Software

/ 20
Date
/

Prof. Dr. Mahmoud E. Gadallah 175


Introduction to Computers Chapter 5 : System Software
/
Date
/ 20

176 Prof. Dr. Mahmoud E. Gadallah


Introduction to Computers

Chapter 6

Application Software

Chapter 6 : Application Software

Prof. Dr. Mahmoud E. Gadallah 177


Introduction to Computers Chapter 6 : Application Software

Introduction
Application software includes all programs designed to perform
specific tasks or applications. Many applications are needed today for
both individual and business requirements.
This chapter discusses some general
Date of lecture

characteristics of application software.


/ / 20

Then the chapter describes some of the


commonly used application programs such
as word processor, spreadsheet, database,
presentation software…etc. It should
be noted that, the application program
introduced in this chapter will be practiced
in the laboratory sessions of this course.
The objectives of this chapter:
After completing this chapter, you will be able to:
....................................................................................................
Note: ......................................................................................

• Describe what application software is, the different types of


ownership rights, and the difference between installed and Web-
based software.
• Detail some concepts and commands that many software programs
have in common.
• Discuss word processing and explain what kinds of documents are
created using this type of program.
• Explain the purpose of spreadsheet software and the kinds of
documents created using this type of program.
• Identify some of the vocabulary used with database software and
discuss the benefits of using this type of program.
• Describe what presentation graphics and electronic slide shows are
and when they might be used.
• Name several other types of application software programs and
discuss what functions they perform.

178 Prof. Dr. Mahmoud E. Gadallah


Introduction to Computers Chapter 6 : Application Software

Software Ownership Rights


Ownership rights of a software program specify the allowable use of
the program.

• Software license: It is an agreement, either included in a software

Date of lecture
package or displayed on the screen during installation that specifies

/ 20
the conditions under which a buyer of the program can use it.

/
The following Figure shows two types of programs: commercial program
and shareware program.

....................................................................................................
Note: ......................................................................................
Software licenses

• Commercial software: copyrighted


software that is developed, usually
by a commercial company, for sale to
others.
• Shareware: copyrighted software that
is distributed on the honor system;
consumers should either pay for it or uninstall it after the trial
period.
• Freeware: copyrighted software that may be used free of charge.
• Public domain software: software that is not copyrighted and may
be used without restriction.

Prof. Dr. Mahmoud E. Gadallah 179


Introduction to Computers Chapter 6 : Application Software

Installed Software vs. Web-based Software


• Installed software: installed on the PC before it can be run.
Installed software programs are either.
• Purchased in physical form.
• Downloaded from the Internet.
Date of lecture

• Web-based software: run directly from the Internet.


/ / 20

• Free (interactive game available through a site).


• Fee-based (application service provider (ASP)).
....................................................................................................
Note: ......................................................................................

180 Prof. Dr. Mahmoud E. Gadallah


Introduction to Computers Chapter 6 : Application Software

Software Suites
• Software suite: a collection of software programs bundled together
and sold as a single software package.
• Office suites: (productivity software suites) are used by most
businesses and many individuals to produce written documents;

Date of lecture
/ 20
typically include:
• Word processing software.

/
• Spreadsheet software.
• Database software.
• Presentation graphics software.

Desktop vs. Mobile Software


• Handheld PCs and mobile devices require special application
software designed for that type of device.

....................................................................................................
Note: ......................................................................................
• Types of mobile software include:
• Calendars and address books.
• Browser, e-mail, and instant messaging programs.
• Language translators and reference software.
• E-books and games.
• Productivity software and specialized applications.
• Some mobile software programs are designed to be compatible
with popular desktop software, such as Microsoft Office.

Prof. Dr. Mahmoud E. Gadallah 181


Introduction to Computers Chapter 6 : Application Software

Common Software Commands


• Application programs today have a number of concepts and
commands in common.
• Editing a document (changing the content of the document).
• Insertion point: indicates the current location in the document
Date of lecture

(where changes will take place).


/ / 20

• Typing text will insert it.


• Delete and Backspace key will delete text.
• Text and objects can typically be selected to be moved, copied,
deleted, or formatted.
....................................................................................................
Note: ......................................................................................

182 Prof. Dr. Mahmoud E. Gadallah


Introduction to Computers Chapter 6 : Application Software
• Formatting a document (changing the appearance of the document),
such as:
• Changing font face, size, style or color.
• Changing line spacing or margins.
• Adding page numbers or borders.

Date of lecture
/ / 20
• Help for a software program includes:
• Help built into the program.
▪ Table of Contents.
▪ Index.

....................................................................................................
Note: ......................................................................................
▪ Search.
• Online help (via manufacturer’s Web site and independent
sites).
• Offline help (periodicals, books, tutorial videos, classes).

Prof. Dr. Mahmoud E. Gadallah 183


Introduction to Computers Chapter 6 : Application Software

Word Processing Concepts


• Word processing is one of the most widely used application
programs today.
• Actual commands and features vary somewhat from program to
program.
Date of lecture

• Important to be familiar with the basic features of word processing


/ / 20

and the general concept of what word processing enables you to do.

What Is Word Processing?



• Word processing: using a computer and word processing
software to create, edit, save, and print written documents, such
as letters, contracts, and manuscripts.
• Like any document created with software instead of paper and
pencil, word processing documents can be retrieved, modified,
....................................................................................................
Note: ......................................................................................

and printed as many times as needed; common word processors


include.
▪ Microsoft Word .
▪ Corel WordPerfect.
▪ Lotus WordPro.

184 Prof. Dr. Mahmoud E. Gadallah


Introduction to Computers Chapter 6 : Application Software
Creating a Word Processing Document:

• Word wrap: feature in a word processing program that
automatically returns the insertion point to the next line when
the end of the screen line is reached.
• Character formatting (font face, size, style, or color).

Date of lecture
• Paragraph formatting (line spacing, left and right margins, tabs,

/ 20
alignment, and styles).

/
• Page formatting (top and bottom margins, paper size,
orientation, headers, footers, etc).
• Document formatting (footnotes, end notes, table of contents,
index, background, theme).

....................................................................................................
Note: ......................................................................................

Prof. Dr. Mahmoud E. Gadallah 185


Introduction to Computers Chapter 6 : Application Software
Tables, Graphics, and Templates:

• Tables: allow content to be organized in a table consisting of
rows and columns.
• Graphics or drawing features: allow images to be inserted
into a document (clip art, photographs, drawn images, etc.) and
Date of lecture

then modified.
/ / 20

• Templates: help users create new documents quickly.


• Wizards: available for creating documents (envelopes,
legal pleadings, calendars, and agendas), as well as for tasks
(sending a fax or publishing a Web page).

Word Processing and the Web:



• Most word processing programs today include Web-related
features, such as to:
▪ Send a document as an e-mail message.
....................................................................................................
Note: ......................................................................................

▪ Include Web page hyperlinks in documents.


▪ Create or modify Web pages.

• Optional file formats for documents created in many word


processing programs include:
▪ Hypertext Markup Language (HTML).
▪ Extensible Markup Language (XML).
▪ Single file Web page or MHTML (MIME Hypertext
Markup Language).

186 Prof. Dr. Mahmoud E. Gadallah


Introduction to Computers Chapter 6 : Application Software

Spreadsheet Concepts
• Spreadsheet software: application software
used to create spreadsheets, documents
which typically contain a great deal of
numbers and mathematical computations

Date of lecture
/ 20
and are organized into rows and columns.

/
• Commonly used by a variety of businesses
and employees, including CEOs,
managers, assistants, analysts, and sales
representatives.

What Is a Spreadsheet?

• Spreadsheet: a group of values and other data organized into
rows and columns.

....................................................................................................
Note: ......................................................................................
▪ Contains numbers and formulas, which automatically
update the spreadsheet as data in the spreadsheet changes.
▪ Worksheet = single spreadsheet.
▪ Workbook = multiple worksheets saved in a single file.

• Most widely used spreadsheet programs:


▪ Microsoft Excel.
▪ Corel Quattro Pro.
▪ Lotus 1-2-3.

Prof. Dr. Mahmoud E. Gadallah 187


Introduction to Computers Chapter 6 : Application Software

Creating a Spreadsheet:

• Data is entered into cells (where rows and columns meet).
• Cells are identified by their cell address, such as B4 or E22.
• Cells can contain:
▪ Labels: text-based entry in a worksheet cell that identifies
Date of lecture

data on the worksheet.


/ / 20

▪ Constant values: numerical entry in a worksheet cell


▪ Formulas: performs mathematical operations on the
content of other cells.
▪ Functions: named programmed formula.
....................................................................................................
Note: ......................................................................................

188 Prof. Dr. Mahmoud E. Gadallah


Introduction to Computers Chapter 6 : Application Software
• Entering formulas and functions:
▪ Begin with the appropriate symbol (usually =).
▪ Use the addresses of the numbers in the formula, not the
numbers themselves:
i.e. =B2+C2 NOT =600+200

Date of lecture
▪ Enter the formula into the cell where the result

/ 20
of the formula should be displayed.

/
▪ Formulas can be edited.
▪ Formulas can be coped to save time.
• Absolute vs. relative cell references:
▪ Relative cell references: cell addresses are adjusted as
the formula is copied; the default in most spreadsheet
programs (B6).
▪ Absolute cell references: cell addresses are not adjusted
as the formula is copied ($B$6).
▪ Use an absolute cell reference when the formulas should

....................................................................................................
Note: ......................................................................................
always use the value in a particular cell, regardless of
which cell the formula is placed in:
• Constant value (sales tax rate, etc.) .
• Percent computation (always divide by total).

Prof. Dr. Mahmoud E. Gadallah 189


Introduction to Computers Chapter 6 : Application Software
Charts and What-If Analysis:

• Most spreadsheet programs include some type of charting or
graphing capability:
▪ Can create graph from the
data in the spreadsheet
Date of lecture

(don’t have to reenter it).


/ / 20

▪ Graphs change accordingly


if the data in the
spreadsheet changes.
• What-if analysis (sensitivity analysis): allows you to change
certain numbers on a spreadsheet and immediately see the
results of that change.
▪ Tool frequently used to help make business decisions.

Spreadsheets and the Web:



....................................................................................................
Note: ......................................................................................

• Most spreadsheet programs have built-in Web capabilities.


• Many spreadsheet programs have an option on the File menu to
save the current worksheet as a Web page.
• Hyperlinks can be inserted into worksheet cells.
• Ranges of cells can be selected and copied to a Web publishing
or word processing program to insert spreadsheet data into a
Web page as a table.

190 Prof. Dr. Mahmoud E. Gadallah


Introduction to Computers Chapter 6 : Application Software

Database Concepts
• Database management system: software used retrieve large
amounts of data rapidly, such as:
• A customer service representative who
needs to find a customer’s order status

Date of lecture
/ 20
while they are on the telephone.
• A university’s registrar who needs a

/
student’s GPA or want to determine if
the student has outstanding fees before
processing his registration.
• A clerk in a video store who needs to determine if a movie is
available and, if not, when it is due to be returned.
• Most common type of database used on PCs today is a relational
database.

....................................................................................................
Note: ......................................................................................
What Is a Database?

• Database: a collection of related data that is stored in a manner
enabling information to be retrieved as needed.
• Database management system (DBMS) (or database
software): application software that allows the creation and
manipulation of an electronic database.
• Most PC-based databases are organized into fields (columns),
records (rows), and files (tables).
• Common relational database management systems (RDBMS)
include:
▪ Microsoft Access.
▪ Corel Paradox.
▪ Lotus Approach.

Prof. Dr. Mahmoud E. Gadallah 191


Date of lecture
Introduction to Computers Chapter 6 : Application Software
/ / 20

Creating a Database:

• Databases can contain a variety of objects (such as tables,
queries, forms, reports).
....................................................................................................
Note: ......................................................................................

• Objects are given names.

192 Prof. Dr. Mahmoud E. Gadallah


Introduction to Computers Chapter 6 : Application Software
• The table structure is specified first:
• Includes a list of fields and their properties, including:
▪ Field name (unique identifying name).
▪ Data type (text, number, date, object).
▪ Field size (maximum number of characters).

Date of lecture
▪ Default value (initial content of the field).

/ 20
• The table is named and saved.

/
• The table structure can be modified using the Design view.
• After the table structure has been created, data is entered
into the table:
▪ Datasheet view: lists all data and looks similar to a
spreadsheet.
▪ Form: created by the user and typically displays just one
record at a time.
▪ In either case, data is entered into the database table.
• Either Datasheet view or a form can be used to modify data

....................................................................................................
Note: ......................................................................................
or delete records.

Prof. Dr. Mahmoud E. Gadallah 193


Introduction to Computers Chapter 6 : Application Software

Queries and Reports:



• Queries: questions, or, in database terms, requests for specific
information from the database.
▪ Contain criteria to specify the records and fields to be
included in the query results.
Date of lecture

▪ Are named and saved so they can be run again at a later


/ / 20

time; the results always include the current database data.


• Reports: created when a more formal output is desired .
....................................................................................................
Note: ......................................................................................

Databases and the Web:



• Many Web sites use one or more databases to:
▪ Keep track of inventory.
▪ Allow searching for people, documents, products, or other
information.
▪ Place real-time orders.
• Anytime you type keywords in a search site or hunt for a
product on a retail store’s Web site using its search feature, you
are using a Web database.

194 Prof. Dr. Mahmoud E. Gadallah


Introduction to Computers Chapter 6 : Application Software

Presentation Graphics Concepts


• If you try to explain to others what you look like, it may take
several minutes. Show them a color photograph, and you can
convey the same information within
seconds.

Date of lecture
/ 20
• The saying “a picture is worth a thousand

/
words” is the cornerstone of presentation
graphics.

What Is a Presentation Graphic?



• Presentation graphic: an image designed to visually enhance
a presentation.
• Can be used in electronic slide shows, as well as in printed

....................................................................................................
Note: ......................................................................................
handouts, overhead transparencies, word processing
documents, and Web pages.
• To create presentation graphics, presentation graphics
software is used. Most common presentation graphics
programs are:
▪ Microsoft PowerPoint.
▪ Corel Presentations.
▪ Lotus Freelance Graphics.

Prof. Dr. Mahmoud E. Gadallah 195


Introduction to Computers Chapter 6 : Application Software

Creating a Presentation:

• Many presentation graphics programs include preformatted
slide layouts containing placeholders for the various elements
in the slide (text, images, charts).
• Slides are created one at a time; new slides can be inserted as
Date of lecture

needed.
/ / 20

• Multimedia objects and animated effects can be used.


• Transitions special effects used between slides can be applied
to specific slides, or random transitions can be selected for the
entire slide show.
....................................................................................................
Note: ......................................................................................

196 Prof. Dr. Mahmoud E. Gadallah


Introduction to Computers Chapter 6 : Application Software
Finishing a Presentation:

• Preview the slides and rearrange them if needed:
▪ Most programs have a way to view thumbnails of all slide
to more easily rearrange them.
• Run the slide show and edit as needed:

Date of lecture
▪ Can be set up to run automatically or on mouse click.

/ 20
• Can usually print the slides to create overhead

/
transparencies or an audience handout.

Presentation Graphics and the Web:



• Presentation graphics programs can be used to generate Web
pages or Web page content.
• Slides can include hyperlinks.
• When a slide show is saved as a series of Web pages and
displayed using a Web browser, generally forward and

....................................................................................................
Note: ......................................................................................
backward navigational buttons are displayed on the slides to
allow the user to control the presentation.

Prof. Dr. Mahmoud E. Gadallah 197


Introduction to Computers Chapter 6 : Application Software

Graphics and Multimedia Concepts


• Graphics are graphical images, such as digital photographs, clip
art, scanned drawings, and original images created using a software
program.
• Multimedia typically refers to sound or video.
Date of lecture

• There is a variety of software programs designed to help


/ / 20

individuals.
• Create or modify graphics.
• Edit digital audio or video.
• Play multimedia files.
• Burn CDs and DVDs.
• Graphics software: used to create or modify images:
• Painting programs: allow you to create bit-mapped images
(Microsoft Paint, Corel’s Paint Shop Pro).
• Drawing programs: typically create images using
....................................................................................................
Note: ......................................................................................

mathematical formulas (Adobe® Illustrator®, Macromedia


Freehand, CorelDRAW).
• Image editing or photo editing programs: designed for
touching up or modifying images.

198 Prof. Dr. Mahmoud E. Gadallah


Introduction to Computers Chapter 6 : Application Software
• Audio editing software: used to create and edit audio files.
• Video editing software: used to modify existing videos, such as:
• Deleting scenes.
• Rearranging scenes.
• DVD authoring software: used to create DVD content, including

Date of lecture
• Importing videos.

/ 20
• Creating menus.

/
• Burning onto a DVD.

....................................................................................................
• CD and DVD burning software: used to record data on Note: ......................................................................................

recordable or rewritable CDs and DVDs.


• Media players: used to play media available via your PC—such as
music CDs or downloaded music or video—as well as online audio
and video clips.
• Graphics and multimedia software is often used by individuals and
businesses alike to create Web sites or content to be shared via the
Web.

Prof. Dr. Mahmoud E. Gadallah 199


Introduction to Computers Chapter 6 : Application Software

Other Types of Application Software


• Desktop and personal publishing software.
• Educational software.
• Entertainment software.
• Reference software.
Date of lecture

• Accounting and personal finance software.


/ / 20

• CAD and other types of design software.


• Project management and collaboration software.
• Note taking and personal productivity software.
....................................................................................................
Note: ......................................................................................

200 Prof. Dr. Mahmoud E. Gadallah


Introduction to Computers Chapter 6 : Application Software

Summary
• The Basics of Application Software.
• Word Processing Concepts.
• Spreadsheet Concepts.
• Database Concepts.

Date of lecture
/ 20
• Presentation Graphics Concepts.
• Graphics and Multimedia Concepts.

/
• Other Types of Application Software.

....................................................................................................
Note: ......................................................................................

Prof. Dr. Mahmoud E. Gadallah 201


Introduction to Computers Chapter 6 : Application Software
/
Date
/ 20

Exercises

202 Prof. Dr. Mahmoud E. Gadallah


Introduction to Computers Chapter 6 : Application Software
1- Match each key term on the left with the definition on the right
that best describes it.

Key term matching Description

1- A collection of related data that is stored in a


a. cell manner enabling information to be retrieved as
needed.

/ 20
Date
/
b. database 2- A collection of related fields in a database. Also
called a row.

3- A collection of worksheets saved in a single


c. field spreadsheet file.

4- An agreement, either included in a software


package or displayed on the screen during
d. formula installation, that specifies the conditions under
which a buyer of the program can use it.
5- An entry in a worksheet cell that performs
e. label computations on worksheet data and displays the
results.

6- A single category of data to be stored in a


f. public domain database, such as a person’s name or telephone
software number. Also called a column.

7- A text-based entry in a worksheet cell that


g. record identifies data on the worksheet.

8- Copyrighted software that is distributed on the


h. shareware honor system; consumers should either pay for it
or uninstall it after the trial period.

9- Software that is not copyrighted and may be used


i. software license without restriction.

10- The location at the intersection of a row and


j. workbook column on a worksheet into which data can be
typed.

Prof. Dr. Mahmoud E. Gadallah 203


Introduction to Computers Chapter 6 : Application Software
2- Circle T if the statement is true and F if the statement is false.
a). T F Microsoft Office is one example of a software suite.
b). T F Changing the font size in a document is an example of a
formatting operation.
c). T F In a word processing document, the Enter key is always pressed
at the end of each screen line to move down to the next line.
/
Date

d). T F The formula =A2+B2 located in cell C2 would multiply the two
/ 20

cells to the left of cell C2.


e). T F Software can be installed on both personal computers and
servers.

3- Write the best answer in the space provided.


a). With a(n) …………….. program, the source code for the program is made
available to the public and so can be modified by others.
b). The blinking vertical line displayed on the screen that indicates the current
location in a document, such as where the next change will be made to the
document in a word processing program, is called the ……….....
c). A named formula (such as @SUM) in a spreadsheet program is called a(n)
……………...
d). In a relational database, the database object that contains the actual data is
the ……………..

204 Prof. Dr. Mahmoud E. Gadallah


Introduction to Computers Chapter 6 : Application Software

/ 20
Date
/
Notes

Prof. Dr. Mahmoud E. Gadallah 205


Introduction to Computers Chapter 6 : Application Software
/
Date
/ 20

206 Prof. Dr. Mahmoud E. Gadallah


Introduction to Computers Chapter 6 : Application Software

/ 20
Date
/

Prof. Dr. Mahmoud E. Gadallah 207


Introduction to Computers Chapter 6 : Application Software
/
Date
/ 20

208 Prof. Dr. Mahmoud E. Gadallah


Introduction to Computers Chapter 6 : Application Software

/ 20
Date
/

Prof. Dr. Mahmoud E. Gadallah 209


Introduction to Computers Chapter 6 : Application Software
/
Date
/ 20

210 Prof. Dr. Mahmoud E. Gadallah


Introduction to Computers

Chapter 7

Computer Networks

Chapter 7 : Computer Networks

Prof. Dr. Mahmoud E. Gadallah 211


Introduction to Computers Chapter 7 : Computer Networks

Introduction
Computer communications means telecommunications in which data
is sent from one device to another using communication media such as
telephone lines, private cables and airwaves. Communications occur
over a private network (such as home or business), the internet, or a
Date of lecture

telephone network.
/ / 20

This chapter aims to introduce the concepts and terminologies


associated with computer networks. After defining a computer
network, the chapter identifies the applications of networking. The
chapter discusses some technical issues related to networks such
as data transmission and the types of
transmission media. The communication
protocols and networking standards are
explained. At the end of this chapter, an
idea about various types of hardware used
....................................................................................................
Note: ......................................................................................

with a computer network is given.


The ILOs of this chapter are:
After completing this chapter, you will be able to:
• Define a network and its purpose.
• Describe several uses for networks.
• Understand the various characteristics of a network, such as
topology, architecture, and size.
• Understand characteristics about data and how it travels over a
network.
• Name specific types of wired and wireless networking media and
explain how they transmit data.
• Identify the most common communications protocols and
networking standards used with networks today.
• List several types of networking hardware and explain the purpose
of each.

212 Prof. Dr. Mahmoud E. Gadallah


Introduction to Computers Chapter 7 : Computer Networks

Definition of a network
A network, in general, is a connected system of objects or people. A
computer network is a collection of computers and other hardware
devices connected together so hat network users can share hardware,
software, and data as well as communicate with each other

Date of lecture
/ 20
electronically. Computer network ranges from small private networks
to the internet.

/
....................................................................................................
Note: ......................................................................................
The telecommunications system
• Telecommunications system: Combination of hardware and
software that transmits information (text, data, graphics, and voice)
from one location to another.
• Analog signal: Continuous waves that transmit information by
altering the amplitude and frequency of the waves.
• Digital signal:
A discrete pulse,
either on or off,
that conveys
information in a
binary form.

Prof. Dr. Mahmoud E. Gadallah 213


Introduction to Computers Chapter 7 : Computer Networks

Analog vs Digital Transmission Terminology


• Analog data take on continuous values in a given interval, e.g.
audio (human speech) or video.
• Digital data take on discrete
values, e.g. text or integers.
Date of lecture

• Signals are electromagnetic


/ / 20

representations of data.
• Signaling is the physical
propagation of the signal along a suitable medium.
• Transmission is the communication of data by the propagation and
processing of signals.

Analog Data - Digital Signals


• Analog signals had the drawback that they attenuate (weaken) over
long distances. Needed amplifiers to boost the signals. However,
....................................................................................................
Note: ......................................................................................

amplifiers distort the signal and introduce noise. Used in early


telephone systems.
• A digital signal is a sequence of binary voltage pulses (0’s and
1’s).
• Digital transmission avoids the noise problem by encoding the
analog signal into digital form. The digitized version is then sent
across the network.
• The transmission of data across a long distance requires a
modulator at one end to modulate the signal, i.e. modify the carrier
wave. A demodulator is required at the other end to demodulate or
reproduce the original signal.
• A modem is a device which performs modulation and
demodulation functions.
• A codec (coder -decoder)converts analog signals to digital data -
used mainly for voice data.
214 Prof. Dr. Mahmoud E. Gadallah
Introduction to Computers Chapter 7 : Computer Networks

Why Digital?
• Ease with which digital signals are generated compared to analog.
• Digital signals are subject to less distortion and interference than
are analog signals.
• Easier to detect and correct errors in digital data.

Date of lecture
/ 20
• Digital circuits are :
▪ more reliable.

/
▪ more flexible.
▪ cheaper.

Communication Modes
Three modes are used to send data over a transmission line as shown
in the following Figure. They are:
• Simplex mode:
In this mode, data is transmitted in one direction only.

....................................................................................................
Note: ......................................................................................
• Half-Duplex mode:
In this mode, data is transmitted in either direction, but not
simultaneously. Used when devices wish to exchange data
alternately.
• Full-Duplex mode:
In this mode, data is transmitted in both directions simultaneously.

Communication modes

Prof. Dr. Mahmoud E. Gadallah 215


Introduction to Computers Chapter 7 : Computer Networks

Uses for computer networks:


1. Sharing an internet connection among several users.
2. Sharing application software, printers, and other resources.
3. Facilitating voice over IP (VOIP), e-mail, video conferencing and
other communication applications.
Date of lecture

4. Working collaboratively, such as sharing a company database or


/ / 20

using collaboration tools to create or review documents.


5. Exchanging files among network users and over the internet
6. Connecting the computers and the entertainment devices, such as
TVs, gaming consoles, and stereo systems located within a home.

Networking and Communications Applications


• Mobile phones (wireless phones).
• Cellular (cell) phones (most common).
• Satellite phones (used where cell service isn’t available).
....................................................................................................
Note: ......................................................................................

Types of mobile phones

• Paging: sending short numeric or text messages to a person’s


pager.
• Most often used for onsite paging applications.
• Messaging: two-way paging.
• Most often takes place today via a mobile phone.

216 Prof. Dr. Mahmoud E. Gadallah


Introduction to Computers Chapter 7 : Computer Networks
• Global positioning system (GPS): Uses satellites and a receiver to
determine the exact geographic location of the receiver.
• Commonly found in cars today.
• Available as handheld units.
• Used by the military, hikers, travelers,

Date of lecture
and others who need to know their

/ 20
precise location.

/
• Monitoring systems: which are used to monitor status of or
location of individuals, vehicles, assets, etc.
• Electronic medical monitors.
• GPS-based monitoring systems.
• RFID short-range monitoring systems.
• Monitoring via the Internet.

• Satellite radio: which delivers digital radio content to satellite

....................................................................................................
Note: ......................................................................................
receivers, which can be.
• Car-mounted.
• Placed in the home.
• Carried around.

• Video conferencing: which use communications technology for


real-time, face-to-face meetings between individuals located in
different places.
• Online conferencing (via the Internet).
• Dedicated videoconferencing room.
• Video phone calls.

Prof. Dr. Mahmoud E. Gadallah 217


Introduction to Computers Chapter 7 : Computer Networks
• Collaborative computing (workgroup computing): using a
computer and communications technology to work together on
documents and other project components.

• Telecommunicating: individuals work at


Date of lecture

home and communicate with their place of


/

business and clients via communications


/ 20

technologies.

• Digital data distribution: transferring digital data (digital


photos, music, movies, TV broadcasts, medical imaging files, etc.)
electronically from one place to another.
• Home use.
• Business use.
• Digital movie distribution.
....................................................................................................
Note: ......................................................................................

• Telemedicine: use of communications technology to provide


medical information and services.
• Remote monitoring and consultations.
• Remote diagnosis.
• Telesurgery.

218 Prof. Dr. Mahmoud E. Gadallah


Introduction to Computers Chapter 7 : Computer Networks

Types of Networks
Networks can be identified by their
• Topology (physical arrangement).
• Architecture (the way they are designed to communicate).
• Size (how large of an area the network services).

Date of lecture
/ 20
Network Topologies:


/
Network topology means the way by which the devices are
connected to form the network. There are different types of
network topologies as shown in the following Figure. From these
topologies:
• Star networks (all devices connect to a central device or hub).
• Bus networks (all devices connect to a central cable).
• Ring networks (devices connect to one another in a ring).
• Mesh networks (multiple connections between devices).

....................................................................................................
Note: ......................................................................................
• Some networks use a combination of topologies.

Computer topologies

Prof. Dr. Mahmoud E. Gadallah 219


Introduction to Computers Chapter 7 : Computer Networks
Network Architectures

Network architecture is concerned with how the data are exchanged
between the devices. From the types of computer architectures are:

• Client-server networks.
Date of lecture

▪ Client: PC or other device on the network that requests


/ / 20

and utilizes network resources.


▪ Server: computer dedicated to processing client requests.
....................................................................................................
Note: ......................................................................................

Client-server network

• Peer-to-peer networks (all computers at the same level).


▪ Internet peer-to-peer (P2P) computing: performed via the
Internet.

220 Prof. Dr. Mahmoud E. Gadallah


Introduction to Computers Chapter 7 : Computer Networks
Classification of computer networks from size point of

view:
LANs, WANs, and Other Types of Networks
• Local area network (LAN): covers a relatively small
geographical area, such as a home, office building, or school.

Date of lecture
/ 20
• Wide area network (WAN): covers a large geographical area;
may consist of two or more LANs, which could be relatively

/
close to one another (such as in the same city) or far apart.
• Metropolitan area network (MAN): designed for a
metropolitan area, typically a city or county.
• Personal area network (PAN): connects personal devices for
one individual, such as his or her portable PC, cell phone, and
portable printer.
• Intranet: private network, such as a company LAN, set up by
an organization for use by its employees.

....................................................................................................
Note: ......................................................................................
• Extranet: intranet that is at least partially accessible to
authorized outsiders.
• Virtual private network (VPN): group of secure paths over
the Internet that provide authorized users a secure means of
accessing a private network via the Internet.

Prof. Dr. Mahmoud E. Gadallah 221


Introduction to Computers Chapter 7 : Computer Networks

How Does Data Travel Over a Network?


• Data transmitted over a network has specific characteristics.
• Data can travel over a network in various ways.
• Network devices can communicate through a.
• Wired connection: via physical cables.
Date of lecture

• Wireless connection: typically through radio signals.


/ / 20

Data Transmission Characteristics


• Analog vs. digital: continuous wave vs. discrete 0s and 1s.
• Bandwidth (throughput): amount of data that can be transmitted
over a communications medium at one time (higher bandwidth will
deliver data faster).
• Serial vs. parallel transmission.
• Serial: one bit a time.
....................................................................................................
Note: ......................................................................................

• Parallel: at least one byte at a time.

Serial versus parallel transmission

222 Prof. Dr. Mahmoud E. Gadallah


Introduction to Computers Chapter 7 : Computer Networks
• Transmission timing:
• Synchronous transmission (at regular, specified intervals).
• Asynchronous transmission (sent when ready).
• Isochronous transmission (sent at the same time as other,
related, data).

Date of lecture
/ 20
• Transmission directions:

/
• Simplex transmission (one way only).
• Half-duplex transmission (one way at a time).
• Full-duplex transmission (both ways at the same time).

Wired vs. Wireless Connections


• Wired network: connection: the PC is physically cabled to the
network.

....................................................................................................
Note: ......................................................................................
• Common in schools, business, and government facilities.
• Wireless networks: typically use radio waves to send data through
the air.
• Rapidly becoming more popular in homes and businesses;
wireless hotspots are commonly available in public locations.

Prof. Dr. Mahmoud E. Gadallah 223


Introduction to Computers Chapter 7 : Computer Networks
Wired Network Transmission Media

• Twisted-pair cable:
▪ Pairs of wires twisted together.
▪ Used for telephone and network connections.
• Coaxial cable:
Date of lecture

▪ Thick center wire.


/ / 20

▪ Used for computer networks, short-run telephone


transmissions, cable television delivery.
• Fiber-optic cable:
▪ Glass or fiber strands through which light can pass.
▪ Used for high-speed communications.
....................................................................................................
Note: ......................................................................................

Wired network transmission media

224 Prof. Dr. Mahmoud E. Gadallah


Introduction to Computers Chapter 7 : Computer Networks
Wireless Network Transmission Media

• Broadcast radio transmissions:
▪ Short-range (such as Bluetooth): can connect a wireless
keyboard or mouse to a PC.
▪ Medium-range (such as Wi-Fi): used for wireless LANs

Date of lecture
and to connect portable PC users to the Internet at public

/ 20
hotspots.

/
• Microwave and satellite transmissions:
▪ Microwave stations (earth based).
▪ Communications satellites (placed in orbit).

....................................................................................................
Note: ......................................................................................
Satellite communications

Prof. Dr. Mahmoud E. Gadallah 225


Introduction to Computers Chapter 7 : Computer Networks
• Cellular radio transmissions:
▪ Use cellular towers within cells.
▪ Calls are transferred from cell tower to cell tower as the
individual moves.
▪ Different transmission frequencies are used to avoid
Date of lecture

interference and allow multiple conversations to take


/

place via a single tower at one time.


/ 20

▪ Widely used, but cell service not available everywhere.


....................................................................................................
Note: ......................................................................................

How cellular phones work

226 Prof. Dr. Mahmoud E. Gadallah


Introduction to Computers Chapter 7 : Computer Networks

Communications Protocols
• Communications protocol:
It is an agreed-upon standard for transmitting data between two
devices on a network.
• Protocols specify how:

Date of lecture
/ 20
• Devices physically connect to a network.
• Data is packaged for transmission.

/
• Receiving devices acknowledge signals (handshaking).
• Errors are handled.

Ethernet
A widely used communications protocol for LANs.
• Typically used with LANs that have a bus or star topology and
use twisted-pair or coaxial cables.
• Original (10Base-T) Ethernet networks run at 10 Mbps; newer

....................................................................................................
Note: ......................................................................................
100 Mbps and 1 Gbps versions are now available.
• Utilizes a set of procedures (CSMA/CD) to send data and make
sure it arrives.

Prof. Dr. Mahmoud E. Gadallah 227


Introduction to Computers Chapter 7 : Computer Networks

Token Ring
Communications protocol usually used with a ring network topology
• Utilizes a token to send and retrieve data.
• Token circulates in one direction.
• Token is either free or carries a message to be delivered to a
Date of lecture

device.
/ / 20

• Each device checks to see if the message is addressed to it.


• Devices can grab a free token and add a message.
....................................................................................................
Note: ......................................................................................

228 Prof. Dr. Mahmoud E. Gadallah


Introduction to Computers Chapter 7 : Computer Networks

Wi-Fi
Wi-Fi (802.11): family of wireless networking standards:
• 802.11b: original standard (11 Mbps).
• 802.11a (Wi-Fi5): about five times
faster than 802.11b; more expensive,

Date of lecture
/ 20
uses a different radio frequency (5
GHz) than 802.11b (2.4 GHz), making

/
the two standards incompatible.
• 802.11g: current Wi-Fi standard; supports data transfer rates of
54 Mbps; it uses the same 2.4 GHz frequency as 802.11b, so
their products are compatible.
• 802.11n (Fast Wi-Fi): in development.

Mesh Networks, WiMAX, Mobile-Fi, and xMax


• Mesh networks: use a mesh topology, so messages can take

....................................................................................................
Note: ......................................................................................
any of several possible paths from source to destination.
▪ Used to connect wireless networks.
▪ Can be used to enlarge hotspot areas.
▪ Can be used to allow emergency workers to communicate
with one another.
▪ Most often used to create MANs.

• WiMAX (802.16): emerging wireless networking standard that


is faster and has a greater range than Wi-Fi.
▪ Expected to provide fast
wireless Internet access over a
distance of up to 30 miles.
▪ Mobile WiMAX is under
development.

Prof. Dr. Mahmoud E. Gadallah 229


Introduction to Computers Chapter 7 : Computer Networks
• Mobile-Fi (802.20): high-speed mobile Internet technology
currently in development.
▪ Expected to be used while moving, such as in cars and
trains.

• xMax: recently developed, for longer range wireless


Date of lecture
/

connections; uses unused portions of radio channels.


/ 20

Bluetooth
Communications standard for very short-range wireless connections.
• The devices are automatically connected once they get within
the allowable range.
• Designed for communications between personal devices
(within 10 meters or 33 feet), such as keyboards and PCs, cell
phones and earpieces, PCs and printers, etc.
....................................................................................................
Note: ......................................................................................

• Devices form piconets of up to 8 devices each.

230 Prof. Dr. Mahmoud E. Gadallah


Introduction to Computers Chapter 7 : Computer Networks

Ultra Wideband (UWB)


Another short-range wireless technology.
• Faster and has a greater range than Bluetooth.
• Originally developed for the military in the 1960s.
• Beginning to be used to wirelessly network consumer

Date of lecture
multimedia devices to wireless deliver digital data (video,

/ 20
music, photos, etc.).

/
• Emerging Bluetooth standards may use UWB to speed up
connections between devices.

TCP/IP and Wireless Application Protocol (WAP)


• TCP/IP: Protocol used for transferring data over the Internet.
• Uses packet switching to facilitate the transmission of
messages.

....................................................................................................
Note: ......................................................................................
• Packets are sent separately and reassembled at the final
destination.
• Also used with home networking.
• Wireless Application Protocol (WAP): Standard for delivering
content, such as Web pages, to mobile devices.

How TCP/IP works

Prof. Dr. Mahmoud E. Gadallah 231


Introduction to Computers Chapter 7 : Computer Networks

Phone line and Power line Networks


• Phone line or Home PNA standard:
• Allows computers to be networked through ordinary phone
wiring and phone jacks, without interfering with voice
telephone calls.
Date of lecture

• Geared toward setting up quick and easy home networks.


/ / 20
....................................................................................................
Note: ......................................................................................

• Power line standard:


• Allows PCs to be networked over existing power lines using
conventional electrical outlets.
• Emerging standard will also connect home entertainment
devices.

232 Prof. Dr. Mahmoud E. Gadallah


Introduction to Computers Chapter 7 : Computer Networks

Networking Hardware
Used to connect a PC to a network.
• Also called network interface card (NIC) when in the form of an
expansion card.

Date of lecture
• Come in a variety of formats.

/ 20
• PCI.

/
• USB.
• PC Card.

• Adapter must match the type of network being used (Ethernet,


WiFi, Bluetooth, etc.).

....................................................................................................
Note: ......................................................................................

Network adapters and modems

Prof. Dr. Mahmoud E. Gadallah 233


Introduction to Computers Chapter 7 : Computer Networks
• Modem: device that connects a computer to the Internet.
• Term used even if not connecting via a phone line.
• Type of modem needed depends on the type of Internet access
being used.
▪ Conventional dial-up.
Date of lecture

▪ ISDN.
/

▪ DSL.
/ 20

▪ Cable.
▪ Satellite.
....................................................................................................
Note: ......................................................................................

• Hubs, switches, routers, and wireless access points: used to


connect devices and route data to the devices on a network.
• Hub: all data goes to all devices.
• Switch: data goes to just appropriate device.
• Router: more efficiently delivers data.
• Wireless access point: connects wireless devices to a wired
network.
• Some devices contain more than one of these capabilities.

234 Prof. Dr. Mahmoud E. Gadallah


Introduction to Computers Chapter 7 : Computer Networks
• Gateways and bridges: connect one network to another.
• Gateway: connects dissimilar networks.
• Bridge: connects similar networks.

• Repeaters: amplify signals on a network so they can travel further.

Date of lecture
/ 20
• Multiplexers and concentrators: combine transmissions from

/
multiple devices to send over a medium and then separates them
again at the destination.

....................................................................................................
Note: ......................................................................................

Networking hardware

Prof. Dr. Mahmoud E. Gadallah 235


Introduction to Computers Chapter 7 : Computer Networks
/
Date
/ 20

Exercises

236 Prof. Dr. Mahmoud E. Gadallah


Introduction to Computers Chapter 7 : Computer Networks
1- Match each key term on the left with the definition on the right
that best describes it.

Key term matching Description

1- A collection of computers and other hardware


devices that are connected together to share
a. antenna hardware, software, and data, as well as to

/ 20
communicate electronically with one another.

Date
/
2- A device used for receiving or sending radio
b. Bluetooth signals; often used to increase the range of a
network.

3- A device used to connect multiple devices on a


c. computer network single (typically wired) network; forwards packets
to only the intended recipient.
4- A networking standard for very short-
range wireless connections; the devices are
d. digital transmission automatically connected once they get within the
allowable range.
5- A network in which there are multiple connections
e. Ethernet between the devices on the network so that
messages can take any of several possible paths.

f. global positioning 6- An emerging wireless networking standard that is


system (GPS) faster and has a greater range than Wi-Fi.

7- A networking protocol that uses packet switching


g. mesh network to facilitate the transmission of messages; the
protocol used with the Internet.

8- A system that uses satellites and a receiver to


h. switch determine the exact geographic location of the
receiver.

9- A type of data transmission where the data is


i. TCP/IP represented by 0s and 1s.

j. WiMAX 10- A widely used wired LAN networking standard.

Prof. Dr. Mahmoud E. Gadallah 237


Introduction to Computers Chapter 7 : Computer Networks
2- Circle T if the statement is true and F if the statement is false.
a). T F GPS systems are used only by the government.
b). T F With serial transmissions, each bit of data is sent individually.
c). T F The Internet is an example of a LAN.
d). T F The type of cable used inside most homes for telephone service is
twisted-pair wire.
/
Date

e). T F A router is a type of modem.


/ 20

3- Write the best answer in the space provided.


a). With a(n) ………… network topology, all devices are connected in a line to a
central cable.
b). A(n) …………. phone can be used with more than one communications
network, such as with both a cellular and Wi-Fi network.
c). A small network designed to connect the personal devices for an individual
(such as via Bluetooth) is called a(n) …………...
d). A(n) ………… is a network that transfers private information securely over
the Internet or other public network.

4- Match each description to its networking application, and write


the corresponding number in the blank to the left of the description.

a. To diagnose a patient from a distance. 1. Multimedia networking

b. To work for a company in New York when 2. GPS


you live in California.

c. To watch a TV show in the living room 3. Telemedicine


that is recorded on your computer.

d. To receive telephone calls while you are 4. Telecommuting


out shopping.

e. To determine your physical location while 5. Cellular phone


hiking in the mountains.

238 Prof. Dr. Mahmoud E. Gadallah


Introduction to Computers Chapter 7 : Computer Networks

/ 20
Date
/
Notes

Prof. Dr. Mahmoud E. Gadallah 239


Introduction to Computers Chapter 7 : Computer Networks
/
Date
/ 20

240 Prof. Dr. Mahmoud E. Gadallah


Introduction to Computers Chapter 7 : Computer Networks

/ 20
Date
/

Prof. Dr. Mahmoud E. Gadallah 241


Introduction to Computers Chapter 7 : Computer Networks
/
Date
/ 20

242 Prof. Dr. Mahmoud E. Gadallah


Introduction to Computers Chapter 7 : Computer Networks

/ 20
Date
/

Prof. Dr. Mahmoud E. Gadallah 243


Introduction to Computers Chapter 7 : Computer Networks
/
Date
/ 20

244 Prof. Dr. Mahmoud E. Gadallah


Introduction to Computers

Chapter 8

Problem Solving and


Program Development
Chapter 8 : Problem Solving and Program Development

Prof. Dr. Mahmoud E. Gadallah 245


Introduction to Computers Chapter 8 : Problem Solving

Introduction
In computing, it is required to have a program that is able to produce
the desired solution of a problem using the computer. To develop a
program, it is necessary to design (plan) the algorithm that describes
the steps of solution. Without this design, the programmer will write a
Date of lecture

bad program or fail entirely to write a program.


/ / 20

In this chapter, the different approaches of designing the algorithms


are described. Writing programs based on an algorithm using a high-
level language (HLL) will be introduced in the next chapter.

Intended Learning Outcomes of the Chapter


On completing this chapter, the student will be able to:

• Solve simple problems analytically.


• Solve simple problems using an algorithm and pseudo code.
....................................................................................................
Note: ......................................................................................

• Write a formal statement from a given problem description.


• Apply the tools for algorithm development: sequence, selection,
and repetition.
• Verify an algorithm using desk checking.
• Incorporate pretty printing into an algorithm.

246 Prof. Dr. Mahmoud E. Gadallah


Introduction to Computers Chapter 8 : Problem Solving

The problem
Most people are faced with a numerous of situations that demand their
attention and force them to think of appropriate actions to take. Some
of these scenarios might be “What should I wear today?” or “Whom
do I have to call and whom should I try to avoid?” or “An accident is

Date of lecture
/ 20
ahead. What deviation should I take?
Each of the above situations can be problematic. That is, you need

/
problem-solving skills to resolve them. Most such problems are
solved without much serious thought. Although some problems are
indeed difficult and illogical, many problems are solvable. You may
not know the best route to take to work but surely there is some
route that will get you there. You may not know the solution to your
physics homework but you know there is an answer. These problems
are solvable but you need a systematic approach to find a reasonably
good answer in a suitable amount of time. In this chapter, we will

....................................................................................................
Note: ......................................................................................
concentrate on simple kinds of problems, those that appear to have a
normal solution.

Prof. Dr. Mahmoud E. Gadallah 247


Introduction to Computers Chapter 8 : Problem Solving

Problem solving approaches


There are three well-known methods of problem solving. The first
is the analytic method used in mathematics and physics. The second
is the algorithmic method used by programmers for simple kinds of
problems, those that appear to have a normal solution. The third is the
Date of lecture

heuristic approach which is used in the case of complex problems.


/ / 20

Both of the second and third methods are necessary steps for computer
program development.
.

These methods have four common solution steps: problem, reasoning,


....................................................................................................
Note: ......................................................................................

solution, and test.


1. Problem: presents the situation that requires a solution.
2. Reasoning: implies a true comprehension of the problem (a brief
idea of it is not enough).
3. Solution: means the process we develop to solve the problem,
which may include insight and practical skills.
4. Test: means the checking process we use to confirm that the
solution is correct.
Normally, algorithmic and heuristic approaches are applied in order to
develop a computer program for the problem under consideration. In
these cases, the program is written (generally in a high-level language)
after designing or planning and testing the algorithm (steps 3 and 4).
Because this course concentrates on simple kinds of problems, the
analytic and algorithmic approaches will be considered in detail.

248 Prof. Dr. Mahmoud E. Gadallah


Introduction to Computers Chapter 8 : Problem Solving

1. The Analytic Approach


The analytic approach is what we use to solve algebra, chemistry, and
physics problems. After reading over a word or story problem several
times, we try to solve it. First we isolate the given quantities, then we
determine what is to be solved, then we apply formulas, then we may

Date of lecture
/ 20
do mathematical operations such as factoring and dividing, and finally
we get an answer. If we are hard-working, we check the answer, often

/
by substituting it back into the original formula. Let’s illustrate this
method with the following simple example.

Example 1:

Problem:
Six identical computers are bought. The total cost is $14,627.50,
which includes $340.00 for shipping and a sales tax of $724.00.
Find the cost of an individual computer, excluding shipping and

....................................................................................................
Note: ......................................................................................
taxes.
Reasoning:
• The input variables:
Number of computers, Total cost, shipping cost and the sales
tax.
• The output:
The cost of an individual computer, excluding shipping and
taxes.
Processes:
To find the cost of one computer:
• Find the total net cost of the six computers = Total cost -
shipping - tax.
• The cost of an individual computer, excluding shipping and
taxes = total net cost of the 6 computers/6.

Prof. Dr. Mahmoud E. Gadallah 249


Introduction to Computers Chapter 8 : Problem Solving
Solution:
Let x be the cost of one computer, and then the cost of all six
computers is 6x. The net cost of the six computers is the total cost
less shipping and tax. In this case
Net cost of the 6 computers = total cost of the 6 computers -
Date of lecture

shipping – tax
/ / 20

Substituting:
Net cost of the 6 computers = $14, 627 .30 - $340.00 - $724.00
= $13, 563 .30
So
6x = $13, 563 .30
x = $13, 563 .30/6 = $2260.55
Test:
A single computer costs $2260.55. T0 check that the answer is
right, substitute the value 2260.55 for X in the original equation.
....................................................................................................
Note: ......................................................................................

That is,
6X + shipping + tax = total cost
So
6(2260.55) + 340.00 + 724.00 = 14,627.30
14,627.30 = 14,627.30

250 Prof. Dr. Mahmoud E. Gadallah


Introduction to Computers Chapter 8 : Problem Solving

2. The Algorithmic Approach


In the algorithmic approach, a finite set of steps is used to solve the
problem.
• Definition of an algorithm:
The algorithm is a sequence of executable instructions with the

Date of lecture
/ 20
following properties:
• No ambiguity between the instructions of the algorithm.

/
• No ambiguity about which instruction is to be executed next.
• Execution of the algorithm ends after a finite number of steps.
• Definition of an executable instruction:
An executable instruction is the instruction that can be carried
out.
• Phases of Algorithmic Problem Solving:
The phases of the algorithmic problem solving approach are four
as follows:

....................................................................................................
Note: ......................................................................................
• Problem: the situation that requires a solution.
• Reasoning: it a formal statement that summarizes the
problem as understood. In this phase, the following 3
components should be determined:
▪ The input or inputs.
▪ The output or outputs.
▪ The process or processes needed to get the output(s)
from the input(s).
• Solution (Design the algorithm): in this phase, one should
describe the algorithm. Two methods can be used to describe
the algorithm:
▪ The flow chart.
▪ The pseudocode.
• Test: it is the hand verification or desk checking.

Prof. Dr. Mahmoud E. Gadallah 251


Introduction to Computers Chapter 8 : Problem Solving
In the solution stage, the algorithm may contain one or more of the
following three control structures:
• Sequence: this means that step by step procedure.
• Selection: this means that choices can be made where necessary.
• Repetition: this means that all or part of the process can be
Date of lecture

repeated.
/ / 20

The following sections will explain these types of structures.


....................................................................................................
Note: ......................................................................................

252 Prof. Dr. Mahmoud E. Gadallah


Introduction to Computers Chapter 8 : Problem Solving

A. Sequence structure
In this structure, the algorithm is based on the concept of ordering the
instructions. In other words, when we write an algorithm we number
the steps. This is both for reference and to stress that there is a specific
order to the algorithm that becomes significant when the algorithm is

Date of lecture
put to use. In this type of algorithms, it is assumed that step n cannot

/ 20
be started until step n – 1 is completed. The following example is an

/
application for the sequence structure.

Example 2:

Develop an algorithm that calculates and prints the area of a
trapezoid with two bases of lengths base1 and base2 and height
h.

Problem:

....................................................................................................
Note: ......................................................................................
Write an algorithm to calculate and print the area of a trapezoid
with two bases of lengths base1 and base2 and height h

Reasoning:
In this step we describe the following:
• Formal statement: trapezoid problem
• Input: base1, base2, height
• Output: area
• Process: area = (base1 + base2) x height / 2

Prof. Dr. Mahmoud E. Gadallah 253


Introduction to Computers Chapter 8 : Problem Solving
Solution (Design the algorithm):
In this step, the solution can be put in the form of a flow chart or
an algorithm written in a pseudo code language.

1. The Flow Chart:


In the flow chart, it is used a set of standard symbols to show
Date of lecture
/

the flow of the processes. The following Figure shows some of


/ 20

the basic flowchart symbols.


....................................................................................................
Note: ......................................................................................

Some basic flowchart symbols

The following Figure shows the flow chart for the previous
example:

254 Prof. Dr. Mahmoud E. Gadallah


Introduction to Computers Chapter 8 : Problem Solving
2. The Algorithm in pseudocode:
Step 1: INPUT base1
Step 2: INPUT base2
Step 3: INPUT height
Step 4: basesum = base1 + base2

Date of lecture
Step 5: area = basesum x height / 2

/ 20
Step 6: OUTPUT area

/
Step 7: STOP
Test:
Desk checks that this sequence of steps is an algorithm whose
execution solves the intended problem. Try the reasonable values
base1 = 10
base2 = 20
Height = 15
Then

....................................................................................................
Note: ......................................................................................
basesum = 10 + 20 = 30
And
Area = 30 x 15/2
= 225

Prof. Dr. Mahmoud E. Gadallah 255


Introduction to Computers Chapter 8 : Problem Solving
You can see that the sequence of steps is critical because it does not
make sense to compute the area of the trapezoid (step 5) until the
basesum has been calculated (step 4). Similarly, the area cannot be
output until it has been calculated.
Date of lecture

Note that we capitalize the words INPUT, OUTPUT, and STOP as


/

part of an algorithm language that is sometimes called pseudocode


/ 20

because of its resemblance to high-level programming languages.


Also, note that the words base1, base2, height, basesum, and area
are in lowercase. These words are not part of the pseudocode but are
arbitrarily chosen to represent the data manipulated by the algorithm.

Mathematically, base1, base2, etc. represent the names of variables


because their values can change depending on the actions taken in
response to the algorithm. In programming they are called identifiers
or variable identifiers because they serve to identify, by name, the
....................................................................................................
Note: ......................................................................................

memory locations in the computer where the corresponding data are


stored. Although the names chosen are arbitrary, as a matter of style it
is better to choose names that are mnemonic-that is, suggest what the
name means.

256 Prof. Dr. Mahmoud E. Gadallah


Introduction to Computers Chapter 8 : Problem Solving

B. Selection
Selection is the choice of alternate paths (branches) depending on
a possibility that may arise in the logical flow of the algorithm. The
ability (and necessity) to allow for possibilities is also the biggest
source of problems with algorithms. When writing an algorithm,

Date of lecture
/ 20
you must think ahead to all possible conditions that might occur and
include steps for appropriate action. This is hard to do and explains

/
why computer software sometimes has hidden problems called bugs.

Example 3:

Problem:
Write an algorithm that accepts a number representing either a
Fahrenheit or a Celsius temperature scale and converts it to the
other scale.

....................................................................................................
Note: ......................................................................................
Reasoning:
To solve this you need to know the formulas for converting from
Fahrenheit to Celsius and from Celsius to Fahrenheit.
Formal statement: temperature conversion problem
Input: scale (Fahrenheit or Celsius), temperature
Output: converted temperature
Process: CelsTemp = 5/9 (FahrenTemp – 32)
FahrenTemp = 9/5 CelsTemp +32

Solution (Design the algorithm):


The algorithm must make a selection based on the user’s input values
and take an appropriate action. The action is dependent on the value
of scale, which is unknown at the time the algorithm is being written.
Therefore, one scale or the other must be expected and processed.

Prof. Dr. Mahmoud E. Gadallah 257


Introduction to Computers Chapter 8 : Problem Solving
1. The algorithm as a flow chart:
Date of lecture
/ / 20

2. The Algorithm in pseudocode:


Step 1: INPUT scale
....................................................................................................
Note: ......................................................................................

Step 2: INPUT temperature


Step 3: IF scale = ‘f ‘ THEN
newTemp = 5/9 x (temperature – 32)
ELSE
newTemp = 9/5 x temperature +32
Step 4: OUTPUT newTemp
Step 5: STOP

Test:
You can easily check this algorithm by trying various values for
temperatures such as 212 Fahrenheit and 100 Celsius, which are
equivalent.

258 Prof. Dr. Mahmoud E. Gadallah


Introduction to Computers Chapter 8 : Problem Solving
Step 3 of the previous example introduces the new pseudocode IF…
THEN…ELSE, which is a selection structure. This can be read
as ‘’ IF it is true that the scale equals f (Fahrenheit), THEN convert
the input temperature to Celsius; otherwise (ELSE) convert it to
Fahrenheit.’’

Date of lecture
Notice that we have introduced pretty printing to show an indentation

/ 20
in the algorithm. In step 3 of the algorithm of the previous example,

/
statements that are affected by the IF statement are indented from the
structure heading to show that they form the body of the selection
structure. Through pretty printing, it should be visually apparent
that step 4 of the example not affected by the selection and is to be
performed after the structure has terminated regardless of which
branch was taken at step 3.

....................................................................................................
Note: ......................................................................................

Prof. Dr. Mahmoud E. Gadallah 259


Introduction to Computers Chapter 8 : Problem Solving
Example 4:

Problem:
Assume that a salesperson is paid a commission based on the
number of sales made during the week. The salesperson is paid a
commission of $8 per sale for fewer that the established quota of
Date of lecture

15 sales, $12 per sale if the quota is reached, and $16 per sale if
/ / 20

the quota is exceeded. Write an algorithm to find the salesperson


commission.

Reasoning:
The problem is to compute a commission based on a pay rate
and number of sales made. The pay rate is specified in three tiers
based on the sales and the preset quota.
Formal statement: sales commission problem
Input: number of sales
....................................................................................................
Note: ......................................................................................

Output: commission
Process: commission = rate x number of sales
Where rate is determined as
$8/sale for fewer than 15 sales
$12/sale for exactly 15 sales
$16/sale for more than 15 sales

Solution:
This problem requires multiple selection based on the input value
of sales, which is unknown at the time the algorithm is being
written.

260 Prof. Dr. Mahmoud E. Gadallah


Introduction to Computers Chapter 8 : Problem Solving
1. The Algorithm in Flow Chart:

Homework:
Draw the
flow chart for
the algorithm

Date of lecture
/ 20
that solves
this problem.

/
2. The Algorithm in pseudocode:
Step 1: INPUT sales

....................................................................................................
Note: ......................................................................................
Step2 : INPUT quota
Step 3: IF sales < quota THEN
Rate = 8
ELSE IF sales = quota THEN
Rate = 12
ELSE
Rate = 16
Step 4: commission = rate x sales
Step 5: OUTPUT commission
Step 6: STOP

Test:
To check this algorithm you must verify that it can handle all the
specified cases. Do this by trying values that are below the quota,
above the quota, and at the quota.

Prof. Dr. Mahmoud E. Gadallah 261


Introduction to Computers Chapter 8 : Problem Solving
Step 2 of the previous example introduces multiple selections and can
be read as ‘’ IF the sales are less than the quota, THEN the rate = 8;
otherwise, IF the sales equal the quota, THEN the rate = 12; otherwise
by default the rate = 16.’’ This structure can be extended indefinitely
by repeated use of ELSE IF.
Date of lecture
/

Notice that in this example, the pay rate must be determined before the
/ 20

commission can be computed (in sequence). Also notice that the last
ELSE of the multiple IF becomes the default or catchall case that is
considered if none of the other possibilities is true. Finally, notice that
for any given run, only one path (one value for rate) can be chosen.
This structure is sometimes called mutual exclusion because choosing
one path excludes all the remaining ones.

Although, input errors are seldom deliberate, one of the rules of


program development is that all input should be tested to ensure that it
....................................................................................................
Note: ......................................................................................

is reasonable within the boundaries of the problem. This is important


to avoid the possible data entry errors (consider an input of negative
number in the previous example). The algorithm will produce an
output which is negative number (illogical output). Here it seems
reasonable that the number of sales must be at least 0 unless returns
are included in the commission scheme. What should the upper bound
be? 100? 1,000? There is no easy answer because whatever number
you choose is arbitrary. More information would be needed about this
particular problem to set an appropriate upper bound.

262 Prof. Dr. Mahmoud E. Gadallah


Introduction to Computers Chapter 8 : Problem Solving

C. Repetition
The third structure used in the development of an algorithm is called
repetition, or looping, which provides for repeated execution of part
of the algorithm. An obvious deficiency in example 4 is its inability to
handle more than one salesperson. You could replicate steps 1 through

Date of lecture
/ 20
4 for each salesperson. Then you have the accounting job of writing
these four steps over and over, especially for a large sales staff, and the

/
problem of hiring and firing. There may be 20 salesperson at one time
and 50 at another. It seems unreasonable to have to expand and shrink
an algorithm depending on the business cycle! One way to deal with
this problem is shown next.

Example 5:

Problem:
Reconsider the problem in example 4 but allow for an entire sales

....................................................................................................
Note: ......................................................................................
staff.

Prof. Dr. Mahmoud E. Gadallah 263


Introduction to Computers Chapter 8 : Problem Solving
Reasoning:
This is essentially the same problem as example 4 with the
addition of a looping structure. The looping structure processes
the data for each salesperson. The input is adjusted to include the
number of salespeople to be paid.
Date of lecture
/

Formal statement: sales commission problem (2)


/ 20

Input: number of salespeople


Number of sales for each salesperson
Output: commission for each salesperson
Process: commission = rate x number of sales
Where rate is determined as
$ 8/sale for < than 15 sales
$12/sale for = 15 sales
$16/sale for > than 15 sales
....................................................................................................
Note: ......................................................................................

Solution:
A loop is used to repeatedly read the data for each salesperson and
compute the associated commission. The word LOOP here means
that the following sequence of steps (2a to 2d in this case) is to be
repeated for a specific number of iterations (numSalespeople in
this case).

264 Prof. Dr. Mahmoud E. Gadallah


Introduction to Computers

Prof. Dr. Mahmoud E. Gadallah


1. The Algorithm in Flow Chart:

265
Chapter 8 : Problem Solving

Note: ...................................................................................... Date of lecture


.................................................................................................... / / 20
Introduction to Computers Chapter 8 : Problem Solving
2. The Algorithm in pseudocode:
Step 1: INPUT numSalespeople
Step 2: LOOP numSalespeople times
INPUT sales
IF sales < quota THEN
Date of lecture

Rate = 8
/

ELSE IF sales = quota THEN


/ 20

Rate = 12
ELSE
Rate = 16
Commission = rate x sales
OUTPUT commission
Step 3: STOP

Test:
....................................................................................................
Note: ......................................................................................

You can test this algorithm by desk checking; that is, by trying
different values for sales (above, below, and at the quota) and
calculating the results.

The algorithm in Example 5 assumes that the number of salespersons


currently on the payroll is known. The loop construction is only
appropriate if the number of iterations can be predetermined as it is
here. For many situations, however, this is not possible and a more
flexible looping structure is needed.

266 Prof. Dr. Mahmoud E. Gadallah


Introduction to Computers Chapter 8 : Problem Solving

/ 20
Date
/
Exercises

Prof. Dr. Mahmoud E. Gadallah 267


Introduction to Computers Chapter 8 : Problem Solving
1- Design a flow chart and pseudo code that receive 2 integers and
calculate / display their Sum and Average.
2- Design a flow chart and pseudo code that receive 2 integers from
the user and Calculate / display their Difference, Product and
quotient.
3- Design Flow chart and pseudo code that will prompt for the price
/

of a computer and tax rate, then calculate the tax and new price,
Date
/ 20

then display them to the screen.


4- Design Flow chart and pseudo code that will prompt for length
and width of a rectangle and radius of a circle, receive them,
then calculate the area of rectangle and area of circle and its
circumference and display them to the screen.
5- Design a flow chart and pseudo code that will receive 3 numbers
then find the maximum and display it to screen.
6- Design a flow chart and pseudo code that will prompt for 2
numbers and accept them then sort them into ascending order, then
display them to the screen.
7- Design a flow chart and pseudo code that will ask for student score
in a subject, and receive it then match the score to a letter(s) grade,
then display grade to the screen. the letter grade is to be calculated
as follows:

Exam Score Assigned Grade


85 and above Ex
75-84 VG
65-74 G
50-64 Pass
Below 50 Fail

268 Prof. Dr. Mahmoud E. Gadallah


Introduction to Computers Chapter 8 : Problem Solving
8- Design a flow chart and pseudo code that accepts pairs of integers
from the user and Calculate / display their Sum, Difference,
Product and quotient. The program will terminate after 5 entries.
9- Design a flow chart and pseudo code that will ask for 10
temperatures expressed in degree Fahrenheit. Then it will accept
each Fahrenheit temperature, then convert it into Celsius, display
the converted temperature to the screen.

/ 20
Date
Celsius = (Fahrenheit - 32) * 5 / 9

/
10- Design a flow chart and pseudo code that will accept pairs of
numbers , calculate the sum, if the sum is +ve then display a
message beside it says “the sum is positive” and if the sum is –ve
then display a message beside it says “the sum is negative”. The
program will terminate after 10 entries is entered.
11- Design a flow chart and pseudo code that will calculate the
factorial of a number and display the result.

Prof. Dr. Mahmoud E. Gadallah 269


Introduction to Computers Chapter 8 : Problem Solving
/
Date
/ 20

Notes

270 Prof. Dr. Mahmoud E. Gadallah


Introduction to Computers Chapter 8 : Problem Solving

/ 20
Date
/

Prof. Dr. Mahmoud E. Gadallah 271


Introduction to Computers Chapter 8 : Problem Solving
/
Date
/ 20

272 Prof. Dr. Mahmoud E. Gadallah


Introduction to Computers Chapter 8 : Problem Solving

/ 20
Date
/

Prof. Dr. Mahmoud E. Gadallah 273


Introduction to Computers Chapter 8 : Problem Solving
/
Date
/ 20

274 Prof. Dr. Mahmoud E. Gadallah


Introduction to Computers Chapter 8 : Problem Solving

/ 20
Date
/

Prof. Dr. Mahmoud E. Gadallah 275


Introduction to Computers

Chapter 9

Introduction to
programming with C++
Language

Chapter 9 : Introduction to programming with C++ Language

276 Prof. Dr. Mahmoud E. Gadallah


Introduction to Computers Chapter 9 : C++ Language

Introduction
The computer program:
The computer program is a set of instructions or statements (code) that
controls the computer to process data, perform computations, make
decisions and activate actions.

Date of lecture
/ 20
Program writing started in the early days of computers with a
language composed of a sequence of binary digits (i.e. 1’s and

/
0’s) called machine language Although these machine instructions
could be directly read and executed by the computer, they were too
cumbersome for humans to read and write.
Later, assembly language was developed to map machine instructions
to English-like abbreviations called.

Finally, high-level programming languages (e.g. FORTRAN (1954),


COBOL (1959), BASIC (1963) and PASCAL (1971)) developed

....................................................................................................
Note: ......................................................................................
which enable people to work with something closer to the words and
sentences of everyday language. With the same concepts, C (1972),
C++ (1988), Java languages were introduced to programmers to with
more and more capabilities.
The instructions written in the high-level languages are automatically
translated by a compiler or interpreter (which is just another program)
into binary machine instructions which can be executed by the
computer.
It should be noted that the “program” is used to describe both the set
of written instructions created by the programmer and also to describe
the entire piece of executable software.

Prof. Dr. Mahmoud E. Gadallah 277


Introduction to Computers Chapter 9 : C++ Language

The C++ Programming Language


The C++ programming language was developed from C and is used
as the standard in software development. For example, the Unix and
Windows operating systems and applications are written in C and
C++. It facilitates both structured and object-oriented programming.
Date of lecture

It is a very powerful language. However, in this course, only the basic


/ / 20

elements of C++ will be covered.

Editing, Compiling and Executing a Simple Program


A simple C++ program to add two numbers
The following is an example of a simple program written in C++.
The program is designed to read two numbers typed by a user
at the keyboard; compute their sum and display the result on the
screen.
----------------------------------------------------------------------------------
....................................................................................................
Note: ......................................................................................

Program to add two integers typed by user at keyboard

#include <iostream>
using namespace std;

int main()
{
int a, b, total;

cout << “Enter integers to be added:” << endl;


cin >> a >> b;
total = a + b;
cout << “The sum is “ << total << endl;

return 0;
}

278 Prof. Dr. Mahmoud E. Gadallah


Introduction to Computers Chapter 9 : C++ Language
An overview of the previous program structure and syntax:

The C++ program consists of a header and a main body with the
following general structure.
----------------------------------------------------------------------------------
Comment statements which are ignored by computer but inform

Date of lecture
reader

/ / 20
#include < header file name>

int main()
{
declaration of variables;
statements;

return 0;
}

....................................................................................................
Note: ......................................................................................

Prof. Dr. Mahmoud E. Gadallah 279


Introduction to Computers Chapter 9 : C++ Language
In the following section, each line of the program is explained. To do
so, the program is rewritten below with line numbers to allow us to
comment the program. Note that line numbers are not used in an actual
program.
Date of lecture

Line number Instruction


/ / 20

1 Program to add two integers typed by user at keyboard

2 #include <iostream>

3 using namespace std;

4 int main()

5 {

6 int a, b, total;

7 cout << “Enter integers to be added:” << endl;


....................................................................................................
Note: ......................................................................................

8 cin >> a >> b;

9 total = a + b;

10 cout << “The sum = “ << total << endl;

11 return 0;

12 }

Line 1
Is a comment which will not be executed. In general, lines
beginning with // indicate that the rest of the line is a comment.
Comments are inserted by programmers to help people read and
understand the program. They can in general be placed anywhere
in a program.

280 Prof. Dr. Mahmoud E. Gadallah


Introduction to Computers Chapter 9 : C++ Language
Line 2
Lines beginning with # are instructions to the compiler’s
preprocessor. The include instruction says “what follows is a file
name, find that file and insert its contents right here”. It is used
to include the contents of a file of definitions which will be used

Date of lecture
in the program. Here the file iostream contains the definitions of

/ 20
some of the symbols used later in the program (e.g. cin, cout).

/
Line 3
Is an advanced feature of C++. It is used to specify that names
used in the program (such as cin and cout) are defined in the
standard C and C++ libraries. This is used to avoid problems with
other libraries which may also use these names.

Line 4

....................................................................................................
Note: ......................................................................................
Every C++ program, irrespective of what it is computing, begins
in such line. When the program is executed, the instructions will
be executed in the order they appear in the main body of the
program. The main body is always started by main() instruction.
This line also specifies that main() will return a value of type
integer (int) on its completion (see line 14).

Line 5
This line contains the opening (left) brace which is used to mark
the beginning of the main body of the program. The main body
consists of instructions which are:
• Declarations: that define the data and
• Statements: that specify how the data should be processed.
Note that, all C++ declarations and statements must end with a
semicolon.

Prof. Dr. Mahmoud E. Gadallah 281


Introduction to Computers Chapter 9 : C++ Language
Line 6
This line is a declaration. The words a, b and total are the names
of variables. A variable is a location in the computer’s memory
where a value can be stored for use by a program. We can assign
and refer to values stored at these locations by simply using the
Date of lecture

variable’s name. The declaration also specifies the variable type.


/

Here the variables a, b and total are declared to be data of type int
/ 20

which means these variables hold integer values. At this stage, the
values of the variables are undefined.

Line 7
This statement instructs the computer to output the string of
characters contained between the quotation marks, followed by
a new line (endl). The location of the output is denoted by cout
which in this case will be the terminal screen.
....................................................................................................
Note: ......................................................................................

Line 8
This statement instructs the computer to read data typed in at
the keyboard (standard input), denoted by cin. These values are
assigned to (stored in) variables a and b.

Line 9
This statement is an arithmetic expression which assigns the
value of the expression a + b (the sum of the integer values stored
at a and b) to the variable total.

282 Prof. Dr. Mahmoud E. Gadallah


Introduction to Computers Chapter 9 : C++ Language
Line 10
This statement instructs the computer to display the value of the
variable total on the terminal screen in the following form:
The sum = the value of total
Then it starts a new line.

Date of lecture
/ 20
Line 11

/
The last instruction of every program is the return statement.
The return statement with the integer value 0 (zero) is used to
indicate to the operating system that the program has terminated
successfully.

Line 12
The closing (right) brace marks the end of the main body of the
program.

....................................................................................................
Note: ......................................................................................
Blank lines
(Lines 4, 8 and 13) have been introduced to make the program
more readable. They will be ignored by the compiler. Whitespace
(spaces, tabs and newlines) are also ignored (unless they are part
of a string of characters contained between quotation marks).
They can be also used to enhance the visual appearance of a
program.

Prof. Dr. Mahmoud E. Gadallah 283


Introduction to Computers Chapter 9 : C++ Language

Indentation
It does not matter where you place statements, either on the same line
or on separate lines. A common and accepted style is that you indent
after each opening brace and move back at each closing brace.
Date of lecture

The development environment and the development


/ / 20

cycle
C++ programs go through 3 main phases during development: editing
(writing the program), compiling (i.e. translating the program to
executable code and detecting syntax errors) and running the program
and checking for logical errors (called debugging).

1. Edit:
The first phase consists of editing a file by
typing in the C++ program with a text editor
....................................................................................................
Note: ......................................................................................

and making corrections if necessary. The


program is stored as a text file on the disk,
usually with the file extension .cc to indicate
that it is a C++ program (e.g. SimpleAdder.cc ).

2. Compile:
A compiler translates the C++ program into machine language
code (object code) which it stores on the disk as a file with the
extension .o ( e.g. SimpleAdder.o). A linker then links the object
code with standard library routines that the program may use
and creates an executable image which is also saved on disk,
usually as a file with the file name without any extension (e.g.
SimpleAdder).

284 Prof. Dr. Mahmoud E. Gadallah


Introduction to Computers Chapter 9 : C++ Language
3. Execute:
The executable is loaded from the disk to memory and the
computer’s processing unit (Central Processing Unit) executes the
program one instruction at a time.

Date of lecture
Variables and Constants

/ / 20
Programs need a way to store the data they use. Variables and
constants offer various ways to represent and manipulate data.
Constants, as the name suggests, have fixed values. Variables, on the
other hand, hold values which can be assigned and changed as the
program executes.

Variable types:

Every variable and constant has an associated type which defines

....................................................................................................
Note: ......................................................................................
the set of values that can be legally stored in it. Variables can be
conveniently divided into integer, floating point, character and
boolean types for representing integer (whole) numbers, floating
point numbers (real numbers with a decimal point), the ASCII
character set (for example ‘a’, ‘b’, ‘A’) and the boolean set (true
or false) respectively.
More complicated types of variable can be defined by a
programmer, but for the moment, we will deal with just the
simple C++ types. These are listed in the following Table:

Variable type Description


int to store a positive or negative integer (whole) number.
float to store a real (floating point) number.
bool to store the logical values true or false.
char to store one of 256 character (text) values.

Prof. Dr. Mahmoud E. Gadallah 285


Introduction to Computers Chapter 9 : C++ Language
Declaration of a Variable:

A variable is introduced into a program by a declaration which
states its type (i.e. int, float , bool or char) and its name, which
you are free to choose. A declaration must take the form:
Date of lecture

Variable type Variable-name;


/ / 20

int count;
float length;
char firstInitial;
bool switched_on;

or

Variable type variable1, variable2, ... variableN;


int myAge, number_throws;
float base, height, areaCircle;
....................................................................................................
Note: ......................................................................................

The variable name can be any sequence of characters consisting


of letters, digits and underscores that do not begin with a digit. It
must not be a special keyword of the C++ language and cannot
contain spaces. C++ is case-sensitive: uppercase and lowercase
letters are considered to be different. Good variable names tell
you how the variable is used and help you understand the flow
of the program. Some names require two words and this can
be indicated by using the underscore symbol (_) or using an
uppercase letter for the beginning of words.

286 Prof. Dr. Mahmoud E. Gadallah


Introduction to Computers Chapter 9 : C++ Language
Storage of variables in computer memory:

When you run your program it is loaded into computer memory
(RAM) from the disk file. A variable is in fact a location in the
computer’s memory in which a value can be stored and later
retrieved. The variable’s name is merely a label for that location

Date of lecture
- a memory address. It may help to think of variables as named

/ 20
boxes into which values can be stored and retrieved.

/
The amount of memory required for the variables depends on
their type. This can vary between machines and systems but is
usually one byte (8 bits) for a char variable, four bytes for an int
and four bytes for a float. This imposes limits on the range of
numbers assigned to each variable. Integer numbers must have
values in the range -2147483648 to 2147483647 (i.e. ±231). Floats
must be real numbers with magnitudes in the range 5.9 x 10-39

....................................................................................................
Note: ......................................................................................
to 3.4 x 1038 (i.e. 2-127 to 2128). They are usually stored using 1
bit for the sign (s), 8 bits for the exponent (e) and 23 bits for the
mantissa (m) such that the number is equal to s x m x 2e. The
ratio of the smallest and largest numbers that can be correctly
added together must therefore be greater than 2-23≈10-7 (i.e. 7
digits of accuracy). This depends only on the number of bits used
to represent the mantissa.

If an application requires very small or large numbers beyond


these ranges, C++ offers two additional data types for integers
and floating point numbers: long and double. Variables of type
double require double the amount of memory for storage but are
useful when computing values to a high precision.

Prof. Dr. Mahmoud E. Gadallah 287


Introduction to Computers Chapter 9 : C++ Language
Assignment of variables:

• Assignment of statements
It is essential that every variable in a program is given a value
explicitly before any attempt is made to use it. It is also very
important that the value assigned is of the correct type.
Date of lecture

The most common form of statement in a program uses the


/ / 20

assignment operator, =, and either an expression or a constant to


assign a value to a variable:
variable = expression;
variable = constant;

The symbol of the assignment operator looks like the


mathematical equality operator but in C++ its meaning is
different. The assignment statement indicates that the value
given by the expression on the right hand side of the assignment
operator (symbol =) must be stored in the variable named on
....................................................................................................
Note: ......................................................................................

the left hand side. The assignment operator should be read as


``becomes equal to’’ and means that the variable on the left hand
side has its value changed to the value of the expression on the
right hand side. For the assignment to work successfully, the type
of the variable on the left hand side should be the same as the
type returned by the expression.
The statement in line 10 of the simple adder program is an
example of an assignment statement involving an arithmetic
expression.

total = a + b;

288 Prof. Dr. Mahmoud E. Gadallah


Introduction to Computers Chapter 9 : C++ Language
It takes the values of a and b, sums them together and assigns
the result to the variable total. As discussed above, variables
can be thought of as named boxes into which values can be
stored. Whenever the name of a box (i.e. a variable) appears
in an expression, it represents the value currently stored in that

Date of lecture
box. When an assignment statement is executed, a new value is

/ 20
dropped into the box, replacing the old one. Thus, line 10 of the

/
program means “get the value stored in the box named a, add it to
the value stored in the box named b and store the result in the box
named total”.
The assignment statement:

total = total + 5;

is thus a valid statement since the new value of total becomes the
old value of total with 5 added to it. Remember the assignment

....................................................................................................
Note: ......................................................................................
operator (=) is not the same as the equality operator in mathematics
(represented in C++ by the operator ==).

• Arithmetic expressions
Expressions can be constructed out of variables, constants,
operators and brackets. The commonly used mathematical or
arithmetic operators include:

Operator Operation
+ addition
- subtraction
* multiplication
/ division
% modulus (modulo division)

Prof. Dr. Mahmoud E. Gadallah 289


Introduction to Computers Chapter 9 : C++ Language
The definitions of the first four operators are as expected. The
modulo division (modulus) operation with an integer is the
remainder after division, e.g. 13 modulus 4 (13%4) gives the
result 1. Obviously it makes no sense at all to use this operator
with float variables and the compiler will issue a warning message
Date of lecture

if you attempt to do so.


/ / 20

Although addition, subtraction and multiplication are the same


for both integers and reals (floating point numbers), division is
different. If you write (see later for declaration and initialization
of variables on the same line):
float a=13.0, b=4.0, result;
result = a/b;

then a real division is performed and 3.25 is assigned to result.


A different result would have been obtained if the variables had
....................................................................................................
Note: ......................................................................................

been defined as integers:


int i=13, j=4, result;
result = i/j;

when result is assigned the integer value 3.


The remainder after integer division can be determined by the
modulo division (modulus) operator, %. For example, the value of
i%j would be 1.

290 Prof. Dr. Mahmoud E. Gadallah


Introduction to Computers Chapter 9 : C++ Language
• Precedence and nesting parentheses
The use of parentheses (brackets) is advisable to ensure the
correct evaluation of complex expressions. Here are some
examples:
4+2*3 equals 10

Date of lecture
/ 20
(4+2)*3 equals 18

/
-3 * 4 equals -12

4 * -3 equals -12 (but should be avoided)

4 * (-3) equals -12

0.5 (a+b) illegal (missing multiplication operator)


equals the average value of a and b only if they are of
(a+b) / 2
type float

The order of execution of mathematical operations is governed

....................................................................................................
Note: ......................................................................................
by rules of precedence. These are similar to those of algebraic
expressions. Parentheses are always evaluated first, followed by
multiplication, division and modulus operations. Addition and
subtraction are last. The best thing, however, is to use parentheses
(brackets) instead of trying to remember the rules.

Prof. Dr. Mahmoud E. Gadallah 291


Introduction to Computers Chapter 9 : C++ Language
Initialization of variables

Variables can be assigned values when they are first defined
(called initialization):

type variable = literal constant;


Date of lecture

float ratio = 0.8660254;


/

int myAge = 19;


/ 20

char answer = ‘y’;


bool raining = false;

The terms on the right hand side are called constants.


(Note the ASCII character set is represented by type char. Each
character constant is specified by enclosing it between single
quotes (to distinguish it from a variable name). Each char variable
can only be assigned a single character. These are stored as
....................................................................................................
Note: ......................................................................................

numeric codes. The initialization of words and character strings


will be discussed later in the section on advanced topics.)
The declaration of a variable and the assignment of its value in
the same statement can be used to define variables as they are
needed in the program.

type variable = expression;


float product = factor1*factor2;

The variables in the expression on the right hand side must of


course have already been declared and had values assigned to
them.

292 Prof. Dr. Mahmoud E. Gadallah


Introduction to Computers Chapter 9 : C++ Language
Warning: When declaring and initializing variables in the middle
of a program, the variable exists (i.e. memory is assigned to
store values of the variable) up to the first right brace that is
encountered, excluding any intermediate nested braces, { }.
For the simple programs described here, this will usually be the

Date of lecture
closing brace mark of the program. However we will see later that

/ 20
brace marks can be introduced in many parts of the program to

/
make compound statements.

Expressions with mixed variable types:



At a low level, a computer is not able to perform an arithmetic
operation on two different data types of data. In general, only
variables and constants of the same type, should be combined
in an expression. The compiler has strict type checking rules to
check for this.

....................................................................................................
Note: ......................................................................................
In cases where mixed numeric types appear in an expression,
the compiler replaces all variables with copies of the highest
precision type. It promotes them so that in an expression with
integers and float variables, the integer is automatically converted
to the equivalent floating point number for the purpose of the
calculation only. The value of the integer is not changed in
memory. Hence, the following is legal:

int i=13;
float x=1.5;
x = (x * i) + 23;

since the values of i and 23 are automatically converted to


floating point numbers and the result is assigned to the float
variable x.

Prof. Dr. Mahmoud E. Gadallah 293


Introduction to Computers Chapter 9 : C++ Language
However the expression:
int i=13, j=4;
float result;
result = i/j;

is evaluated by integer division and therefore produces the


Date of lecture

incorrect assignment of 3.0 for the value of result. You should try
/ / 20

and avoid expressions of this type but occasionally you will need
to compute a fraction from integer numbers. In these cases the
compiler needs to be told specifically to convert the variables on
the right-hand side of the assignment operator to type float. This
is done by casting.
In the C++ language this is done by using the construction:
   static_cast< type > expression
(In the C language this is done by a different construction using:
(type) expression.)
....................................................................................................
Note: ......................................................................................

For example:
int count=3, N=100;
float fraction;
fraction = static_cast<float>(count)/N;

converts (casts) the value stored in the integer variable count into
a floating point number, 3.0. The integer N is then promoted into
a floating point number to give a floating point result.

294 Prof. Dr. Mahmoud E. Gadallah


Introduction to Computers Chapter 9 : C++ Language
Declaration and initialization of symbolic constants:

Like variables, symbolic constants have types and names. A
constant is declared and initialized in a similar way to variables
but with a specific instruction to the compiler that the value
cannot be changed by the program. The values of constants must

Date of lecture
always be assigned when they are created.

/ 20
   

/
const   type constant-name = literal constant;
const   int MAX = 10000;
const   float Pi = 3.14159265;

The use of constants helps programmers avoid inadvertent


alterations of information that should never be changed. The use
of appropriate constant names instead of using the numbers also
helps to make programs more readable.

....................................................................................................
Note: ......................................................................................

Prof. Dr. Mahmoud E. Gadallah 295


Introduction to Computers Chapter 9 : C++ Language

Simple Input and Output


C++ does not, as part of the language, define how data is written to a
screen, nor how data is read into a program. This is usually done by
“special variables” (objects) called input and output streams, cin and
cout, and the insertion and extraction operators. These are defined
Date of lecture
/

in the header file called iostream. To be able to use these objects and
/ 20

operators you must include the file iostream at the top of your program
by including the following lines of code before the main body in your
program.
#include <iostream>
using namespace std;

Printing to the screen using output stream:



A statement to print the value of a variable or a string of
characters (set of characters enclosed by double quotes) to the
....................................................................................................
Note: ......................................................................................

screen begins with cout, followed by the insertion operator, («)


which is created by typing the ``less than’’ character (<) twice.
The data to be printed follows the insertion operator.

 cout << text to be printed ;


 cout << variable ;
 cout <<  endl;

296 Prof. Dr. Mahmoud E. Gadallah


Introduction to Computers Chapter 9 : C++ Language
The symbol endl is called a stream manipulator and moves the
cursor to a new line. It is an abbreviation for end of line.
Strings of characters and the values of variables can be printed
on the same line by the repeated use of the insertion operator. For
example (line 11 of the simple adder program):

Date of lecture
/ 20
int total = 12;

/
cout << “The sum is “ << total << endl;
prints out
The sum is 12

and then moves the cursor to a new line.

Input of data from the keyboard using input stream:



The input stream object cin and the extraction operator, (»),
are used for reading data from the keyboard and assigning it to

....................................................................................................
Note: ......................................................................................
variables.
variable ;
cin  >>   
cin  >>    variable1  >>   variable2 ;

Data typed at the keyboard followed by the return or enter key is


assigned to the variable. The value of more than one variable can
be entered by typing their values on the same line, separated by
spaces and followed by a return, or on separate lines.

Prof. Dr. Mahmoud E. Gadallah 297


Introduction to Computers Chapter 9 : C++ Language

Control Statements
The statements in the programs presented above have all been
sequential, executed in the order they appear in the main program.

In many programs the values of variables need to be tested, and


Date of lecture

depending on the result, different statements need to be executed. This


/ / 20

facility can be used to select among alternative courses of action. It


can also be used to build loops for the repetition of basic actions.

Boolean expressions and relational operators:



In C++ the testing of conditions is done with the use of Boolean
expressions which yield bool values that are either true or
false. The simplest and most common way to construct such an
expression is to use the so-called relational operators.
....................................................................................................
Note: ......................................................................................

x==y true if x is equal to y.


x!=y true if x is not equal to y.
x>y true if x is greater than y.
x>=y true if x is greater than or equal to y.
x<y true if x is less then y.
x<=y true if x is less than or equal to y.

Be careful to avoid mixed-type comparisons. If x is a floating


point number and y is an integer the equality tests may not work
as expected.

298 Prof. Dr. Mahmoud E. Gadallah


Introduction to Computers Chapter 9 : C++ Language
Compound Boolean expressions using logical operators

If you need to test more than one relational expression at a time, it
is possible to combine the relational expressions using the logical
operators.

Date of lecture
operator C++ symbol Example

/ / 20
AND && or and expression1 && expression2
OR || or or expression1 or expression2
NOT ! !expression

The meaning of these will be illustrated in examples below.

The IF selection control statement:




....................................................................................................
Note: ......................................................................................
The simplest and most common selection structure is the if
statement which is written in a statement of the form:
if( boolean-expression ) statement;
The if statement tests for a particular condition (expressed as a
boolean expression) and only executes the following statement(s)
if the condition is true. An example follows of a fragment of
a program which tests if the denominator is not zero before
attempting to calculate fraction.

if(total != 0)
fraction = counter/total;

If the value of total is 0, the boolean expression above is false and


the statement assigning the value of fraction is ignored.

Prof. Dr. Mahmoud E. Gadallah 299


Introduction to Computers Chapter 9 : C++ Language
If a sequence of statements is to be executed, this can be done by
making a compound statement or block by enclosing the group
of statements in braces.

   if( boolean-expression )
   {
Date of lecture
/

        statements;
/ 20

   }

An example of this is:

if(total != 0)
{
fraction = counter/total;
cout << “Proportion = “ << fraction << endl;
}
....................................................................................................
Note: ......................................................................................

The IF/ELSE selection control statement:



Often it is desirable for a program to take one branch if the
condition is true and another if it is false. This can be done by
using an if/else selection statement:

   if( boolean-expression )
        statement-1;
   else
        statement-2;

300 Prof. Dr. Mahmoud E. Gadallah


Introduction to Computers Chapter 9 : C++ Language
Again, if a sequence of statements is to be executed, this is done
by making a compound statement by using braces to enclose the
sequence:

   if( boolean-expression )
   {

Date of lecture
/ 20
        statements;
   }

/
   else
   {
        statements;
   }

-----------------------------------------------------------------------------------
An example occurs in the following fragment of a program to
calculate the roots of a quadratic equation.

//testing for real solutions to a quadratic

....................................................................................................
Note: ......................................................................................
d = b*b - 4*a*c;
if(d >= 0.0)
{
// real solutions
root1 = (-b + sqrt(d)) / (2.0*a);
root2 = (-b - sqrt(d)) / (2.0*a);
real_roots = true;
}
else
{
// complex solutions
real = -b / (2.0*a);
imaginary = sqrt(-d) / (2.0*a);
real_roots = false;
}

Prof. Dr. Mahmoud E. Gadallah 301


Introduction to Computers Chapter 9 : C++ Language
If the boolean condition is true, i.e. (d≥0), the program calculates
the roots of the quadratic as two real numbers. If the boolean
condition tests false, then a different sequence of statements is
executed to calculate the real and imaginary parts of the complex
roots. Note that the variable real_roots is of type bool. It is
Date of lecture

assigned the value true in one of the branches and false in the
/

other.
/ 20

ELSE IF multiple selection statement:



Occasionally a decision has to be made on the value of a variable
which has more than two possibilites. This can be done by placing
if statements within other if-else constructions. This is commonly
known as nesting and a different style of indentation is used to
make the multiple-selection functionality much clearer. This is
given below:
....................................................................................................
Note: ......................................................................................

   if( boolean-expression-1 )
        statement-1;
   else if( boolean-expression-2 )
        statement-2;
   
   else
        statement-N;

For compound statement blocks, braces must be used.

302 Prof. Dr. Mahmoud E. Gadallah


Introduction to Computers Chapter 9 : C++ Language
SWITCH selection control statement:

Instead of using multiple if/else statements C++ also provides a
special control structure, switch.
For a variable x the switch(x) statement tests whether x is equal to
the constant values x1, x2, x3, etc. and takes appropriate action.

Date of lecture
The default option is the action to be taken if the variable does not

/ 20
have any of the values listed.

/
   switch( x )
   {
      case x1:                                    
          statements1;
          break;
 
      case x2:
          statements2;
          break;

....................................................................................................
Note: ......................................................................................
      case x3:
          statements3;
          break;

      default:
          statements4;
          break;
   }

Prof. Dr. Mahmoud E. Gadallah 303


Introduction to Computers Chapter 9 : C++ Language
The break statement causes the program to proceed to the first
statement after the switch structure. Note that the switch control
structure is different to the others in that braces are not required
around multiple statements.
The following example uses the switch statement to produce
Date of lecture

a simple calculator which branches depending on the value of


/

the operator being typed in. The operator is read and stored as a
/ 20

character value (char). The values of char variables are specified


by enclosing them between single quotes. The program is
terminated (return -1) if two numbers are not input or the simple
arithmetic operator is not legal. The return value of -1 instead of 0
signals that an error took place.
....................................................................................................
Note: ......................................................................................

304 Prof. Dr. Mahmoud E. Gadallah


Introduction to Computers Chapter 9 : C++ Language

// CalculatorSwitch.cc
// Simple arithmetic calculator using switch() selection.
#include <iostream>
using namespace std;
int main()

Date of lecture
{

/ 20
float a, b, result;
char operation;

/
// Get numbers and mathematical operator from user
input
cin >> a >> operation >> b;

// Character constants are enclosed in single quotes


switch(operation)
{
case ‘+’:
result = a + b;
break;

....................................................................................................
Note: ......................................................................................
case ‘-’:
result = a - b;
break;
case ‘*’:
result = a * b;
break;
case ‘/’:
result = a / b;
break;
default:
cout << “Invalid operation. Program terminated.”
<< endl;
return -1;
}
// Output result
cout << result << endl;
return 0;
}

Prof. Dr. Mahmoud E. Gadallah 305


Introduction to Computers Chapter 9 : C++ Language
The WHILE repetition control statement:

Repetition control statements allow the programmer to specify
actions which are to be repeated while some condition is true. In
the while repetition control structure:
Date of lecture

   while( boolean-expression )
/

   {                             
/ 20

       statements;
   }

the boolean expression (condition) is tested and the statements


(or statement) enclosed by the braces are (is) executed repeatedly
while the condition given by the boolean expression is true. The
loop terminates as soon as the boolean expression is evaluated
and tests false. Execution will then continue on the first line after
the closing brace.
....................................................................................................
Note: ......................................................................................

Note that if the boolean expression is initially false the statements


(or statement) are not executed. In the following example the
boolean condition becomes false when the first negative number
is input at the keyboard. The sum is then printed. (Double click on
the icon with the file name AddWhilePositive.cc and compile and
run the program.

306 Prof. Dr. Mahmoud E. Gadallah


Introduction to Computers Chapter 9 : C++ Language
// AddWhilePositive.cc
// Computes the sum of numbers input at the keyboard.
// The input is terminated when input number is negative.
#include <iostream>
using namespace std;
int main()

Date of lecture
{

/ 20
float number, total=0.0;
cout << “Input numbers to be added: “ << endl;

/
cin >> number;
// Stay in loop while input number is positive
while(number >= 0.0)
{
total = total + number;
cin >> number;
}
// Output sum of numbers
cout << total << endl;
return 0;

....................................................................................................
Note: ......................................................................................
}

Increment and decrement operators:



Increasing and decreasing the value of an integer variable is a
commonly used method for counting the number of times a loop
is executed. C++ provides a special operator ++ to increase the
value of a variable by 1. The following are equivalent ways of
incrementing a counter variable by 1.
count = count + 1;
count++;

The operator -- decreases the value of a variable by 1. The


following are both decrementing the counter variable by 1.
count = count - 1;
count--;

Prof. Dr. Mahmoud E. Gadallah 307


Introduction to Computers Chapter 9 : C++ Language
The FOR repetition control statement:

Often in programs we know how many times we will need to
repeat a loop. A while loop could be used for this purpose by
setting up a starting condition; checking that a condition is true
and then incrementing or decrementing a counter within the
Date of lecture

body of the loop. For example we can adapt the while loop in
/ / 20

AddWhilePositive.cc so that it executes the loop N times and


hence sums the N numbers typed in at the keyboard.

int i=0; // initialise counter


while(i<N) // test whether counter is still less
than N
{
cin >> number;
total = total + number;
i++; // increment counter
}
....................................................................................................
Note: ......................................................................................

The initialisation, test and increment operations of the while loop


are so common when executing loops a fixed number of times
that C++ provides a concise representation - the for repetition
control statement:

for(int i=0; i<N; i++)


{
cin >> number;
total = total + number;
}

308 Prof. Dr. Mahmoud E. Gadallah


Introduction to Computers Chapter 9 : C++ Language
This control structure has exactly the same effect as the while
loop listed above.
The following is a simple example of a for loop with an increment
statement using the increment operator to calculate the sample
mean and variance of N numbers. The for loop is executed N

Date of lecture
times.

/ 20
(Double click on the icon with the file name ForStatistics.cc

/
and compile and run the program. Change the value of N (both
negative and positive numbers) to make sure you understand the
operation of both while and for loops.)

//ForStatistics.cc
//Computes the sample mean and variance of N numbers input
at the keyboard.
//N is specified by the user but must be 10 or fewer in
this example.

....................................................................................................
Note: ......................................................................................
#include <iostream>
using namespace std;
int main()
{
int N=0;
float number, sum=0.0, sumSquares=0.0;
float mean, variance;

// Wait until the user inputs a number in correct range


(1-10)
// Stay in loop if input is outside range
while(N<1 || N>10)
{
cout << “Number of entries (1-10) = “;
cin >> N;
}

Prof. Dr. Mahmoud E. Gadallah 309


Introduction to Computers Chapter 9 : C++ Language
// Execute loop N times
// Start with i=1 and increment on completion of loop.
// Exit loop when i = N+1;
for(int i=1; i<=N; i++ )
{
cout << “Input item number “ << i << “ = “;
Date of lecture

cin >> number;


/

sum = sum + number;


/ 20

sumSquares = sumSquares + number*number;


}
mean = sum/N;
variance = sumSquares/N - mean*mean;

cout << “The mean of the data is “ << mean <<


“ and the variance is “ << variance << endl;
return 0;
}

A more general form of the for repetition control statement is


....................................................................................................
Note: ......................................................................................

given by:

   for( statement1; boolean-expression; statement3 )     


   {
       statement2;
   }

The first statement (statement1) is executed and then the boolean


expression (condition) is tested. If it is true statement2 (which
may be more than one statement) and statement3 are executed.
The boolean expression (condition) is then tested again and if
true, statement2 and statement3 are repeatedly executed until the
condition given by the boolean expression becomes false.

310 Prof. Dr. Mahmoud E. Gadallah


Introduction to Computers Chapter 9 : C++ Language

/ 20
Date
/
Exercises

Prof. Dr. Mahmoud E. Gadallah 311


Introduction to Computers Chapter 9 : C++ Language
1. Refer to H. M. Deitel, P. J. Deitel and T. R. Nieto, C++ in the Lab,
Prentical Hall, third edition, 2002. to solve the following questions:
1. No 29 , page 11
2. No 32 , page 13
3. No 33 , page 14
4. No 25 , page 53
/
Date
/ 20

5. No 28 , page 54
6. No 30 , page 55
7. No 34 , page 15
8. No 37 , page 16
9. No 39 , page 17
10. No 32 , page 57
11. No 34 , page 58
12. No 36 , page 59
13. No 39 , page 60

2. Write programs for all the problems given in the exercise of


Chapter 9 using C++ programming language. Apply these programs
in the Lab.

312 Prof. Dr. Mahmoud E. Gadallah


Introduction to Computers Chapter 9 : C++ Language

/ 20
Date
/
Notes

Prof. Dr. Mahmoud E. Gadallah 313


Introduction to Computers Chapter 9 : C++ Language
/
Date
/ 20

314 Prof. Dr. Mahmoud E. Gadallah


Introduction to Computers Chapter 9 : C++ Language

/ 20
Date
/

Prof. Dr. Mahmoud E. Gadallah 315


Introduction to Computers Chapter 9 : C++ Language
/
Date
/ 20

316 Prof. Dr. Mahmoud E. Gadallah


Introduction to Computers Chapter 9 : C++ Language

/ 20
Date
/

Prof. Dr. Mahmoud E. Gadallah 317


Introduction to Computers Chapter 9 : C++ Language
/
Date
/ 20

318 Prof. Dr. Mahmoud E. Gadallah

You might also like