Introduction To Computers Color
Introduction To Computers Color
Introduction To Computers Color
Introduction to Computers
1st Computer Science
Prepared by
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.
It should be noted that, these lecture notes are prepared as a handout for
students based mainly on the following reference:
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.
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
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
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: ......................................................................................
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
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
Date of lecture
• Interface unit.
/ 20
• Memory:
/
• Short-term storage for CPU
calculations.
• Communication devices:
....................................................................................................
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
• 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: ......................................................................................
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).
....................................................................................................
Note: ......................................................................................
• Supercomputers.
• Mainframes.
• Minicomputers (midrange servers).
• Microcomputers (personal computers).
• Mobile devices.
• Embedded computers.
1. Supercomputers
• Size:
Supercomputers are the most powerful and most expensive type
of computer.
• Used for:
Date of lecture
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.
• Operated by:
/ / 20
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: ......................................................................................
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.
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: ......................................................................................
4. System configuration.
/ / 20
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.
function properly.
• The system: is configured from
the operating system’s registry.
• Drivers: are loaded into
memory.
• Volume control.
• Antivirus software.
• PC card unplugging utility.
Abbreviations
Abbreviation Definition
Date of lecture
CPU Central Processing Unit
/ 20
ALU Arithmetic Logic Unit
/
CU Control Unit
....................................................................................................
Note: ......................................................................................
OS Operating System
Exercises
/ 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 …………….. .
Notes
/ 20
Date
/
/ 20
Date
/
/ 20
Date
/
Chapter 2
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: ......................................................................................
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.
Date of lecture
/ 20
Used to represent numeric,
/
text-based, and multimedia data,
as well as to represent programs.
....................................................................................................
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.
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.
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
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.
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: ......................................................................................
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: ......................................................................................
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
....................................................................................................
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
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
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.
....................................................................................................
Note: ......................................................................................
4386810 = 0AB5C16
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
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
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
Date of lecture
/ 20
with PCs
EBCDIC (Extended Binary-Coded
/
Decimal Interchange Code):
developed by IBM, primarily for
mainframe use.
....................................................................................................
Note: ......................................................................................
language
Machine Language
Machine language: binary-based language for representing computer
programs the computer can execute directly.
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
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.
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
• 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: ......................................................................................
Memory
RAM (random access memory): temporary memory that the
computer uses.
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.
....................................................................................................
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
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.
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: ......................................................................................
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: ......................................................................................
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.
51
Chapter 2 : The System Unit
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.
....................................................................................................
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.
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.
3D chips:
....................................................................................................
Note: ......................................................................................
/ 20
Date
/
Exercises
i. RAM (random 9. The part of the CPU that coordinates its operations.
access memory)
/ 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.
the ………………..
/ 20
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.
/ 20
Date
e. (2309) 10
/
f. (45) 10
g. (285) 10
h. (217.625) 10
i. (125.5) 10
j. (257.875) 10
f. (1288) 10
g. (8275) 10
h. (387) 10
i. (719) 10
j. (1050) 10
c. (285)10
/ 20
e. (111000101.101)2
Date
/
f. (100000100.010)2
e. (50007)8
Date
/ 20
f. (4056)8
g. (727)8
/ 20
e. (3459B)16
Date
/
f. (30C7)16
g. (C00AB)16
h. (3459B)16
i. (AACC5)16
j. (FFFFF)16
Notes
/ 20
Date
/
/ 20
Date
/
/ 20
Date
/
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.
....................................................................................................
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.
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: ......................................................................................
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.
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: ......................................................................................
stored.
....................................................................................................
Note: ......................................................................................
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: ......................................................................................
Date of lecture
/ 20
• Sometimes referred to as a legacy drive and not included on all
new PCs today.
/
....................................................................................................
Note: ......................................................................................
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.
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).
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.
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: ......................................................................................
• Divided into tracks and sectors like magnetic disks but use a
/ / 20
• 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.
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).
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).
Date of lecture
/ 20
• Also called USB mini drives, USB flash drives, thumb
/
drives, jump drives, and key drives.
....................................................................................................
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.
Date of lecture
/ 20
Example for online storage applications are Google Docs, Flickr
/
photo sharing service and social networking sites like Facebook.
....................................................................................................
Note: ......................................................................................
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
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.
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.
Exercises
/ 20
Date
/
b. file 2- A hard drive that uses flash memory media instead
of metal magnetic hard disks.
/ 20
Date
/
Notes
/ 20
Date
/
/ 20
Date
/
Chapter 4
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: ......................................................................................
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: ......................................................................................
Can be:
• Wireless .
• Portable.
• Foldable .
• Handheld PCs and mobile devices today often have a built-in
Date of lecture
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.
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: ......................................................................................
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
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.
document.
/ / 20
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.
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
• Code 39.
• POSTNET code.
....................................................................................................
Note: ......................................................................................
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: ......................................................................................
or tailed.
....................................................................................................
Note: ......................................................................................
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.
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
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: ......................................................................................
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
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: ......................................................................................
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
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:
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.
Date of lecture
/ / 20
How OLED displays work
....................................................................................................
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.
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
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: ......................................................................................
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
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: ......................................................................................
Multifunction Devices
Audio Output:
• Audio output:
Output in the form of voice or music.
Date of lecture
/ / 20
/ 20
Date
/
Exercises
/ 20
Date
e). T F An ink-jet printer normally produces a better image than a laser
/
printer.
Notes
/ 20
Date
/
/ 20
Date
/
/ 20
Date
/
Chapter 5
System Software
Operating Systems
and Utility Programs
Programs
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.
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: ......................................................................................
• 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…
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: ......................................................................................
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
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).
....................................................................................................
Note: ......................................................................................
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.
....................................................................................................
Note: ......................................................................................
versions.
/ / 20
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: ......................................................................................
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.
communications.
/ 20
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.
....................................................................................................
Note: ......................................................................................
the release of its predecessor, Windows 7, in 2009.
Mac OS:
proprietary operating system for computers
made by Apple Corporation.
user interfaces.
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: ......................................................................................
Linux:
version (flavor) of UNIX available without charge over the
Internet.
• Increasingly being used with PCs, servers,
mainframes, and supercomputers.
Date of lecture
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.
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.
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: ......................................................................................
stand-alone programs.
/
• 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
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: ......................................................................................
Exercises
/ 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.
phones.
/ 20
/ 20
Date
/
Notes
/ 20
Date
/
/ 20
Date
/
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
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
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.
....................................................................................................
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.
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).
and the general concept of what word processing enables you to do.
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: ......................................................................................
then modified.
/ / 20
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.
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
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).
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.
Creating a Database:
• Databases can contain a variety of objects (such as tables,
queries, forms, reports).
....................................................................................................
Note: ......................................................................................
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.
Date of lecture
/ 20
• The saying “a picture is worth a thousand
/
words” is the cornerstone of presentation
graphics.
....................................................................................................
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.
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
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.
....................................................................................................
Note: ......................................................................................
backward navigational buttons are displayed on the slides to
allow the user to control the presentation.
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: ......................................................................................
Date of lecture
• Importing videos.
/ 20
• Creating menus.
/
• Burning onto a DVD.
....................................................................................................
• CD and DVD burning software: used to record data on Note: ......................................................................................
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: ......................................................................................
Exercises
/ 20
Date
/
b. database 2- A collection of related fields in a database. Also
called a row.
d). T F The formula =A2+B2 located in cell C2 would multiply the two
/ 20
/ 20
Date
/
Notes
/ 20
Date
/
/ 20
Date
/
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
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.
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.
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
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.
....................................................................................................
Note: ......................................................................................
receivers, which can be.
• Car-mounted.
• Placed in the home.
• Carried around.
technologies.
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
• Client-server networks.
Date of lecture
Client-server network
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.
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).
....................................................................................................
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.
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
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.
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
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.
....................................................................................................
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.
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: ......................................................................................
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.
....................................................................................................
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.
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.
....................................................................................................
Note: ......................................................................................
▪ ISDN.
/
▪ DSL.
/ 20
▪ Cable.
▪ Satellite.
....................................................................................................
Note: ......................................................................................
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
Exercises
/ 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.
/ 20
Date
/
Notes
/ 20
Date
/
/ 20
Date
/
Chapter 8
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
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.
Both of the second and third methods are necessary steps for computer
program development.
.
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.
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
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.
repeated.
/ / 20
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
The following Figure shows the flow chart for the previous
example:
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
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
Test:
You can easily check this algorithm by trying various values for
temperatures such as 212 Fahrenheit and 100 Celsius, which are
equivalent.
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: ......................................................................................
15 sales, $12 per sale if the quota is reached, and $16 per sale if
/ / 20
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.
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.
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.
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.
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).
265
Chapter 8 : Problem Solving
Rate = 8
/
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.
/ 20
Date
/
Exercises
of a computer and tax rate, then calculate the tax and new price,
Date
/ 20
/ 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.
Notes
/ 20
Date
/
/ 20
Date
/
/ 20
Date
/
Chapter 9
Introduction to
programming with 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.
....................................................................................................
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.
#include <iostream>
using namespace std;
int main()
{
int a, b, total;
return 0;
}
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: ......................................................................................
2 #include <iostream>
4 int main()
5 {
6 int a, b, total;
9 total = a + b;
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.
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.
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.
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.
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
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: ......................................................................................
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).
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:
int count;
float length;
char firstInitial;
bool switched_on;
or
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.
total = a + b;
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)
Date of lecture
/ 20
(4+2)*3 equals 18
/
-3 * 4 equals -12
....................................................................................................
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.
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.
....................................................................................................
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;
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.
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;
....................................................................................................
Note: ......................................................................................
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;
Date of lecture
/ 20
int total = 12;
/
cout << “The sum is “ << total << endl;
prints out
The sum is 12
....................................................................................................
Note: ......................................................................................
variables.
variable ;
cin >>
cin >> variable1 >> variable2 ;
Control Statements
The statements in the programs presented above have all been
sequential, executed in the order they appear in the main program.
Date of lecture
operator C++ symbol Example
/ / 20
AND && or and expression1 && expression2
OR || or or expression1 or expression2
NOT ! !expression
....................................................................................................
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( boolean-expression )
{
Date of lecture
/
statements;
/ 20
}
if(total != 0)
{
fraction = counter/total;
cout << “Proportion = “ << fraction << endl;
}
....................................................................................................
Note: ......................................................................................
if( boolean-expression )
statement-1;
else
statement-2;
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.
....................................................................................................
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;
}
assigned the value true in one of the branches and false in the
/
other.
/ 20
if( boolean-expression-1 )
statement-1;
else if( boolean-expression-2 )
statement-2;
else
statement-N;
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;
}
the operator being typed in. The operator is read and stored as a
/ 20
// 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;
....................................................................................................
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;
}
while( boolean-expression )
/
{
/ 20
statements;
}
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: ......................................................................................
}
body of the loop. For example we can adapt the while loop in
/ / 20
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;
given by:
/ 20
Date
/
Exercises
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
/ 20
Date
/
Notes
/ 20
Date
/
/ 20
Date
/