0% found this document useful (0 votes)
6 views105 pages

Computer Science Handout

This document provides an introduction to computer systems, detailing their functionalities, components, and the processes of data input, processing, storage, and output. It also discusses the advantages and disadvantages of using computers, highlighting characteristics such as speed, accuracy, and versatility, while addressing health risks, privacy concerns, and environmental impacts. Overall, it serves as a foundational overview of how computers operate and their implications in society.

Uploaded by

kehinde soneye
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
6 views105 pages

Computer Science Handout

This document provides an introduction to computer systems, detailing their functionalities, components, and the processes of data input, processing, storage, and output. It also discusses the advantages and disadvantages of using computers, highlighting characteristics such as speed, accuracy, and versatility, while addressing health risks, privacy concerns, and environmental impacts. Overall, it serves as a foundational overview of how computers operate and their implications in society.

Uploaded by

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

CHAPTER ONE

THE COMPUTER SYSTEM

1.0 Introduction to Computer

A computer is an electronic device, operating under the control of instructions stored


in its own memory that can accept data (input), process the data according to specified rules,
produce information (output), and store the information for future use.
Data and Information: Data are things known or assumed as facts that make the basis of
reasoning or calculation. It is a set of values of qualitative or quantitative variables about one
or more persons or objects on which operations are performed by a computer, which may be
stored and transmitted in the form of electrical signals. Information is a data that has
meaning or a processed fact. Computers process data into information. As seen in Figure 1.1,
data is a collection of unprocessed items, which can include text, numbers, images, audio,
and video. Data is processed into Information to conveys meaning that is useful to people.

Processing

Data Information

Figure 1.1. A Computer


1.1 Functionalities of a Computer
Any digital computer carries out five functions as follows
 Takes data as input
 Store the data and instructions in its memory for use when required
 Processes the data to converts it to useful information
 Generate the output
 Controls all the operation inside the computer.

1.2 A Computer System


A computer system is a basic, complete and functional computer, including all the hardware
and software required to make it functional for a user. It should have the ability to receive
user input, process data, and with the processed data, create information for storage and
output. Figure 1.2 gives detail of basic operation of a typical computer system.
Storage Unit
Program & Data Input Unit Output Unit

Results

Control Unit

Central Processing Unit

Arithmetic
Logic Unit

Figure: 1.2: Basic Operation of a computer


1.2.1 Input Unit: This is the process of entering data and programs in to the computer
system. This uses input device which is any peripheral (piece of computer hardware
equipment) to provide data and control signals to an information processing system such as a
computer or other information appliance. Input device translate data from that humans
understand to one that the computer can work with. Most common are keyboard, mouse and
others as shown in figure 1.3.

Figure 1.3: Examples of Input Devices

1.2.2 Processing/ System Units: The task of performing operations like arithmetic and
logical operations is called processing. The Central Processing Unit (CPU) takes data and
instructions from the storage unit and makes all sorts of calculations based on the
instructions given and the type of data provided. It is then sent back to the storage unit.
This is further discuss in this section.

Central Processing Unit (CPU): A CPU is the brain of a computer. It is responsible for
all functions and processes. Regarding computing power, the CPU is the most important
element of a computer system.
The CPU is comprised of three main parts:
(a) Arithmetic Logic Unit (ALU): Executes all arithmetic and logical operations.
Arithmetic calculations like addition, subtraction, multiplication and division. Logical
operation like compare numbers, letters, or special characters
(b) Control Unit (CU): Controls and Co-ordinates computer components by performing
the following functions:
 Reads the code for the next instruction to be executed.
 Increments the programs counter so it points to the next instruction.
 Reads whatever data the instruction requires from cells in memory.
 Provides the necessary data to an ALU or register.
 If the instruction requires an ALU or specialized hardware to complete,
instructs the hardware to perform the requested operation.
(c) Registers: Stores the data that is to be executed next, "very fast storage area".

1.2.3 Storage Unit: The process of saving data and instructions permanently is known as
Storage or Memory. Data has to be fed into the system before the actual processing starts.
The processing speed of Central Processing Unit (CPU) is so fast; data has to be provided to
CPU with the same speed. Therefore, the data is first stored in the storage unit for faster
access and processing. It provides space for storing data and instructions. There are four
types of memory or storage:
(a) Primary Memory
(i) RAM: Random Access Memory (RAM) is a type of primary memory scheme within the
computer system. It is responsible for storing data on a temporary basis, so that it can be
promptly accessed by the processor as and when needed. It is volatile in nature, which
means that data will be erased once power supply to the storage device is turned off. RAM
stores data randomly and the processor accesses these data randomly from the RAM
storage. RAM is considered "random access" because you can access any memory cell
directly if you know the row and column that intersect at that cell.
There are two types of RAM as it can be seen in figure 1.4, which are DRAM (Dynamic
Random Access Memory) and SRAM (Static Random Access Memory)

Figure 1.4: (a) Static Ram (b) Dynamic Ram

(ii) ROM (Read Only Memory): ROM is a permanent form of storage. ROM stays active
regardless of whether power supply to it is turned on or off. ROM devices do not allow data
stored on them to be modified.

Types of ROM
 Programmable Read Only Memory (PROM): This can be programmed with a special
machine as opposed to using the expensive masks needed to produce large volumes of
roll chips. Once a PROM is programmed, its contents cannot be changed.
 Erasable Programmable Read Only Memory (EPROM). This type of ROM is designed
so that its contents can be erased using ultra-violet light. Then the chip can be re-
programmed. Disadvantages of EPROM are that its contents do not last as long as
those of other types of ROM. because sunlight contains ultra-violet rays, you must
protect EPROM chips from exposure to sunlight. Figure 1.5 is a diagrammatical
example of a ROM
Figure 1.5: ROM
(iii) Cache: This is a high speed access area that can be either are served section of main
memory or a storage device memory. It is a chip-based computer component that makes
retrieving data from the computer's memory more efficient. It acts as a temporary storage
area that the computer's processor can retrieve data from easily. Most computers today
come with L3 cache or L2 cache, while older computers included only L1cache.

(iv) Registers: The CPU processes data and instructions with high speed; there is also
movement of data between various units of the computer. It is necessary to transfer the
processed data with high speed. So the CPU (esp. ALU) uses a number of special memory
units called registers. They are not part of the main memory but they temporarily store data or
information used by the ALU and passes it on as directed by the control unit.

(b) Secondary Memory: This stores data and programs permanently and it is retained
after the power is turned off.
(i). Hard Drive (HD): A hard disk is part of a unit, often called a "disk drive," "hard
drive," or "hard disk drive," that store and provides relatively quick access to large
amounts of data on an electromagnetically charged surface or set of surfaces.
Figure 1.6 (a) and (b) are examples of internal and external hard disk respectively.

Figure 1.6: (a) Internal Hard disk (b) External Hard Disk
(ii).Optical Disk: an Optical Disc Drive (ODD) is a disk drive that uses laser light as
part of the process of reading or writing data to or from optical discs. Some drives
can only read from discs, but recent drives are commonly both readers and
recorders, also called burners or writers. Compact discs, DVDs, and Blu-ray discs
are common types of optical media which can be read and recorded by such drives.
Optical drive is the generic name; drives are usually described as "CD" "DVD", or
"Bluray", followed by "drive", "writer", etc. CDs can store up to 700 megabytes
(MB) of data and DVDs can store up to 8.4 GB of data. Blu-ray discs, which are
the newest type of optical media, can store up to 50 GB of data. This storage
capacity is a clear advantage over the floppy disk storage media (a magnetic
media), which only has a capacity of 1.44 MB

(iii) Magnetic Tape: This is a magnetically coated strip of plastic on which data can be
encoded as shown in figure 1.7 • Tapes for computers are similar to tapes used to
store music. • Tape is much less expensive than other storage mediums but
commonly a much slower solution that is commonly used for backup.
Figure 1.7: Magnetic Tape
.(iv) Floppy Disk: This as shown in figure 1.8 is a soft magnetic disk. • Floppy disks are
portable. • Floppy disks are slower to access than hard disks and have less storage
capacity, but they are much less expensive. • Can store data up to 1.44MB. • Two
common sizes: 5 ¼” and 3 ½”.

Figure 1.8: Floppy Disk


(v) USB Flash Drive : A small, portable flash memory card that plugs into a computer’s
Universal Serial Bus (USB) port and functions as a portable hard drive. • Flash drives
are available in sizes such as 256MB, 512MB, 1GB, 5GB, and 16GB and are an easy
way to transfer and store information. Example is in Figure 1.9.

Figure 1.9: USB Flash Drive


(vi) Memory Card: An electronic flash memory storage disk commonly used in
consumer electronic devices such as digital cameras, MP3 players, mobile phones,
and other small portable devices. • Memory cards are usually read by connecting the
device containing the card to your computer, or by using a USB card reader.
Examples of different memory card are given in figure 1.10.

Figure 1.10: Memory Cards

Storage measurements: The basic unit used in computer data storage is called a bit (binary
digit). Computers use these little bits, which are composed of ones and zeros, to do things and
talk to other computers. All your files, for instance, must be kept in the computer as binary
files and translated into words and pictures by the software (which is also ones and zeros).
This two number system is called a “binary number system” since it has only two numbers in
it. The decimal number system in contrast has ten unique digits, zero through nine.
Computer Storage units

Bit BIT 0 or 1
Kilobyte KB 1024 bytes
Megabyte MB 1024 kilobytes
Gigabyte GB 1024 megabytes
Terabyte TB 1024 gigabytes
Petabtye PB 1024 terabyte
Exabyte EB 1024 petabyte
Yottabyte YB 1024exabyte

1.2.4 Output Unit: An output device is any piece of computer hardware equipment used to
communicate the results of data processing carried out by an information processing system
(such as a computer) which converts the electronically generated information into human-
readable form. Examples of output devices are displayed in figure 1.11.

Figure 1.11: Examples of Output Devices

Basic types of monitors are Cathode Ray Tube (CRT), Liquid Crystal Displays (LCD), Light-
Emitting Diode (LED). Printer types are Laser Printer, Ink Jet Printer and Dot Matrix Printer.

1.3 Advantages / Characteristics of Computer


Speed, accuracy, diligence, storage capability and versatility are some of the key
characteristics of a computer. Brief overviews of these characteristics are:
(i) Speed: The computer can process data very fast, at the rate of millions of instructions
per second. Some calculations that would have taken hours and days to complete
otherwise, can be completed in a few seconds using the computer. For example,
calculation and generation of salary slips of thousands of employees of an organization,
weather forecasting that requires analysis of a large amount of data related to
temperature, pressure and humidity of various places, etc.
Speed measurement: The speed of Central Processing Unit (CPU) is measured by
Hertz (Hz), which represent a CPU cycle. The speed of CPU is known as Computer
Speed
CPU SPEED MEASURES
1 hertz or Hz 1 cycle per second
1 MHz 1 million cycles per second or 1000Hz
1 GHz 1 billion cycles per second or 1000 MHz

(ii) Accuracy: Computer provides a high degree of accuracy. For example, the computer
can accurately give the result of division of any two numbers up to 10 decimal places.
(iii) Diligence: When used for a longer period of time, the computer does not get tired or
fatigued. It can perform long and complex calculations with the same speed and
accuracy from the start till the end.
(iv) Storage Capability: Large volumes of data and information can be stored in the
computer and also retrieved whenever required. A limited amount of data can be stored,
temporarily, in the primary memory. Secondary storage devices like floppy disk and
compact disk can store a large amount of data permanently.
(v) Versatility: Computer is versatile in nature. It can perform different types of tasks with
the same ease. At one moment you can use the computer to prepare a letter document
and in the next moment you may play music or print a document. Computers have
several limitations too. Computer can only perform tasks that it has been programmed
to do.
(vi) Automation: Once a program is in the computer's memory, it can run automatically
each time it is opened. The individual has little or no instruction to give again.
(vii) Reliability: Being a machine, a computer does not suffer human traits of tiredness and
lack of concentration. It will perform the last job with the same speed and accuracy as
the first job every time even if ten billion jobs are involved.
(viii) Flexibility: It can perform any type of task once it can be reduced to logical steps.
Modern computers can be used to perform a variety of functions like on-line
processing, multi-programming, real time processing etc.
(ix) Resource and File sharing: It allows for more convenient resource sharing. This benefit
is very important, particularly for larger companies that really need to produce huge
numbers of resources to be shared to all the people. Since the technology involves
computer-based work, it is assured that the resources they wanted to get across would
be completely shared by connecting to a computer network which their audience is also
using.
(x) Communication and Information: It enhances communication and availability of
information. Networking, especially with full access to the web, allows ways of
communication that would simply be impossible before it was developed. Instant
messaging can now allow users to talk in real time and send files to other people
wherever they are in the world, which is a huge boon for businesses. Also, it allows
access to a vast amount of useful information, including traditional reference materials
and timely facts, such as news and current events

1.4 Disadvantages of using Computers


Some disadvantages of computers relate to health risks, the violation of privacy, public
safety, the impact on the labour force, and the impact on the environment.
 Health Risks: Prolonged or improper computer use can lead to injuries or disorders
of the hands, wrists, elbows, eyes, neck, and back. Computer users can protect
themselves from these health risks through proper workplace design, good posture
while at the computer, and appropriately spaced work breaks.
 Violation of Privacy: Nearly every life event is stored in a computer somewhere in
medical records, credit reports, tax records, etc. In many instances, where personal
and confidential records were not protected properly, individuals have found their
privacy violated and identities stolen.
 Public Safety: Adults, teens, and children around the world are using computers to
share publicly their photos, videos, journals, music, and other personal information.
Some of these unsuspecting, innocent computer users have fallen victim to crimes
committed by dangerous strangers.
 Impact on Labor Force: Although computers have improved productivity in many
ways and created an entire industry with hundreds of thousands of new jobs, the
skills of millions of employees have been replaced by computers. Thus, it is crucial
that workers keep their education up-to-date. A separate impact on the labor force is
that some companies are outsourcing jobs to foreign countries instead of keeping
their homeland labor force employed.
 Impact on Environment: Computer manufacturing processes and computer waste are
depleting natural resources and polluting the environment. When computers are
discarded in landfills, they can release toxic materials and potentially dangerous
levels of lead, mercury, and flame retardants.

1.5 Brief Overview of the Computer


The evolution of computer digital computing is often divided into earliest computer and
generations. This is fully discussed in section 1.6.1 and 1.6.2.

1.5.1 Earliest Computer


Originally, calculations were computed by humans, whose job title was computers. These
human computers were typically engaged in the calculation of a mathematical expression.
The calculations of this period were specialized and expensive, requiring years of training in
mathematics. The first use of the word "computer" was recorded in 1613, referring to a
person who carried out calculations, or computations, and the word continued to be used in
that sense until the middle of the 20th century. A tally stick was an ancient memory aid
device to record and document numbers, quantities, or even messages.
An abacus is a first mechanical device used to aid an individual in performing mathematical
calculations. The abacus was invented in Babylonia in 2400 B.C. The abacus in the form we
are most familiar with was first used in China in around 500 B.C. It is used to perform basic
arithmetic operations. Napier’s Bones was invented by John Napier in 1614. This allowed
the operator to multiply, divide and calculate square and cube roots by moving the rods
around and placing them in specially constructed boards. Slide Rule was invented by
William Oughtred in1622. It was based on Napier's ideas about logarithms. Primarily, it was
used for multiplication, division, roots, logarithms and Trigonometry. It was not normally
used for addition or subtraction. Pascaline was invented by Blaise Pascal in 1642. It has
limitation to addition and subtraction and it is too expensive.

Another earlier computer is Stepped Reckoner which was invented by Gottfried Wilhelm
Leibniz in 1672. The machines that can add, subtract, multiply and divide automatically. Also
we have Jacquard Loom called a mechanical loom, invented by Joseph-Marie Jacquard in
1881. It an automatic loom controlled by punched cards. There is Arithmometer, a
mechanical calculator invented by Thomas de Colmar in 1820, The first reliable, useful and
commercially successful calculating machine. This machine could perform the four basic
mathematic functions and it was the first mass-produced calculating machine.
First Computer Programmer is Augusta Ada who wrote programs for the Analytical Engine
in 1840.
Scheutzian Calculation Engine was invented also by Per Georg Scheutz in 1843 and it was
based on Charles Babbage's difference engine which is also first printing calculator.
Tabulating Machine was also invented by Herman Hollerithin in 1890 this assist in
summarizing information and accounting. Mark 1 also known as IBM Automatic Sequence
Controlled Calculator (ASCC) was invented by Howard H. Aiken in 1943and this is the first
electro-mechanical computer. Z1 was the first programmable computer, created by Konrad
Zusein Germany from 1936 to 1938. To program the Z1, it required that the user insert punch
tape into a punch tape reader and all output was also generated through punch tape.
Atanasoff-Berry Computer (ABC) was the first electronic digital computing device
invented by Professor John Atanasoff and graduate student Clifford Berry at Iowa State
University between 1939 and 1942

1.5.2 Computer Generations


There are five generations of computer:
(a) First generation (1946 -1958): The first computers used vacuum tubes for circuitry
and magnetic drums for memory, and were often enormous, taking up entire rooms.
They were very expensive to operate and in addition to using a great deal of
electricity, It generated a lot of heat, which was often the cause of malfunctions. First
generation computers relied on machine language, the lowest-level programming
language understood by computers, to perform operations, and they could only solve
one problem at a time. The input was based on punched cards and paper tape, and
output was displayed on printouts.
(b) Second generation (1959 -1964): Transistors replaced vacuum tubes and ushered in
the second generation of computers. One transistor replaced the equivalent of 40
vacuum tubes and this allows computers to become smaller, faster, cheaper, more
energy-efficient and more reliable. It still generated a great deal of heat that can
damage the computer. Second-generation computers moved from cryptic binary
machine language to symbolic, or assembly, languages, which allowed programmers
to specify instructions in words. Second-generation computers still relied on punched
cards for input and printouts for output. These were also the first computers that
stored their instructions in their memory, which moved from a magnetic drum to
magnetic core technology.
(c) Third generation (1965 -1970): The development of the integrated circuit was the
hallmark of the third generation of computers. Transistors were miniaturized and
placed on silicon chips, called semiconductors, which drastically increased the speed
and efficiency of computers. This is much smaller and cheaper compare to the second
generation computers. It could carry out instructions in billionths of a second. Users
interacted with third generation computers through keyboards and monitors and
interfaced with an operating system, which allowed the device to run many different
applications at one time with a central program that monitored the memory.
Computers for the first time became accessible to a mass audience because they were
smaller and cheaper than their predecessors.
(d) Fourth generation (1971 –today): The microprocessor brought the fourth generation of
computers, as thousands of integrated circuits were built onto a single silicon chip. As
these small computers became more powerful, they could be linked together to form
networks, which eventually led to the development of the Internet. Fourth generation
computers also saw the development of GUIs, the mouse and handheld devices.
(e) Fifth generation (Today to future): This is based on Artificial Intelligence (AI) and
still in development. The use of parallel processing and superconductors is helping to
make artificial intelligence a reality. The goal is to develop devices that respond to
natural language input and are capable of learning and self-organization. There are
some applications, such as voice recognition, that are being used today.

1.6. Classification of Computer


Computers may be classified based on the following:
i. Operating principles / Signal Type (based on their construction and
working)
ii. Applications
iii. Size and capability (or classification into micro, mini, mainframe and
supercomputers)
iv. Number of Microprocessors
v. Word length and
vi. Number of users

Classification based on Operating Principles / Signal type


Based on the operating principles, computers can be classified into one of the following
types:
A. Digital Computers
B. Analog Computers
C. Hybrid Computers

A. Digital Computers: - Operate essentially by counting. All quantities are expressed


as discrete or numbers. Digital computers are useful for evaluating arithmetic
expressions and manipulations of data (such as preparation of bills, ledgers, solution
of simultaneous equations etc)
B. Analog Computers:- An analog computer is a form of computer that uses the
continuously changeable aspects of physical phenomena such
as electrical, mechanical, or hydraulic quantities to model the problem being solved.
In contrast, digital computers represent varying quantities symbolically, as their
numerical values change.
There are two useful properties of the analog computer once it is programmed:
 It is simple to change the value of a constant or coefficient and study the effect
of such changes.
 It is possible to link certain variables to a time pulse to study changes with
time as a variable, and chart the result on an X-Y plotter.

C. Hybrid Computers:- are computers that exhibit features of analog


computers and digital computers. The digital component normally serves as the
controller and provides logical operations, while the analog component normally
serves as a solver of differential equations.

Classification based on area of applications


Modern computers depending upon their applications are classified as: -
A Special Purpose Computers
B General Purpose Computers

A. Special Purpose Computers: - A special purpose computer is designed only to


meet the requirements of a particular task or application. The instructions needed
to perform a particular task are permanently stored into the internal memory, so
that it can perform the given task on a single command. It therefore doesn’t
posses unnecessary options and is less expensive.
Examples of special purpose computers include:
 Computers designed specifically to solve navigational problems.
 Computers designed for tracking airplanes or missiles
 Computers used for process control applications in industries such as oil
refinery, chemical manufacture, steel processing and power generation.
 Computers used as robots in factories like vehicle assembly plants and glass
industries.
Special-purpose computers are usually very efficient for the tasks for which they
are specially designed. They are very much less complex than the general-
purpose computers. The simplicity of the circuitry stems from the fact that
provision is made only for limited facilities. They are typically cheaper than the
general-purpose type since they involve fewer components and are less complex
depending on the application.

B. General Purpose Computers: - A General Purpose computers are designed to


meet the needs of many different applications. In these computers, the
instructions needed to perform a particular task are wired permanently into the
internal memory. When one job is over, instructions for another job can be
loaded into the internal memory for processing. This, a general purpose machine
can be used to prepare pay-bills, manage inventories, print sales report and so
on.
Examples of areas where general purpose computers are employed include the
following:
 Payroll
 Banking
 Billing
 Sales analysis
 Cost accounting
 Manufacturing/Scheduling
 Inventory control
The general Attributes of general-purpose computers include:
 General-purpose computers are more flexible than special purpose
computers. Thus, the former can handle a wide spectrum of problems.
 They are relatively less efficient than the special-purpose computers
due to such problems as the following:
o They have inadequate storage
o They have low operating speed
o Coordination of the various tasks and subsections may take time.
 General-purpose computers are typically more complex than special
purpose computers.

Classification of Digital Computer based on size and Capability


Based on size and capability, computers are broadly classified into:

a) Microcomputers (Personal Computer)

A microcomputer is the smallest general purpose processing system. The older pc started 8
bit processor with speed of 3.7MB and current pc 64 bit processor with speed of 4.66 GB.
Examples: - IBM PCs, APPLE computers

Microcomputer can be classified into 2 types :


1. Desktops
2. Portables / Personal
The difference is portables can be used while travelling whereas desktops computers cannot
be carried around.
The different portable computers are: -
 Laptop
 Notebooks
 Palmtop (hand held)
 Wearable computers

Laptop: - this computer is similar to a desktop computers but the size is smaller. They are
expensive than desktop. The weight of laptop is around 3 to 5 kg. Examples of laptop brands
are HP, Dell, Lenovo, Apple, Acer etc
Notebook: - These computers are as powerful as desktop but size of these computers are
comparatively smaller than laptop and desktop. They weigh 2 to 3 kg. They are more costly
than laptop.
Palmtop (Hand held): - They are also called as personal Digital Assistant (PDA). These
computers are small in size. They can be held in hands. It is capable of doing word
processing, spreadsheets and hand writing recognition, game playing, faxing and paging.
These computers are not as powerful as desktop computers. Ex: - 3com palmV.
Wearable computer: - The size of this computer is very small so that it can be worn on the
body. It has smaller processing power. It is used in the field of medicine. For example pace
maker to correct the heart beats. Insulin meter to find the levels of insulin in the blood.

b) Minicomputer: -
A minicomputer is a medium-sized computer. That is more powerful than a microcomputer.
These computers are usually designed to serve multiple users simultaneously (Parallel
Processing). They are more expensive than microcomputers.
Examples: Digital Alpha, Sun Ultra.

c) Mainframe computers:
Computers with large storage capacities and very high speed of processing (compared to
mini- or microcomputers) are known as mainframe computers. They support a large number
of terminals for simultaneous use by a number of users like ATM transactions. They are also
used as central host computers in distributed data processing system.
Examples: - IBM 370, S/390.

d) Supercomputer: -
Supercomputers have extremely large storage capacity and computing speeds which are
many times faster than other computers. A supercomputer is measured in terms of tens of
millions Instructions per second (mips), an operation is made up of numerous instructions.
The supercomputer is mainly used for large scale numerical problems in scientific and
engineering disciplines such as Weather analysis.
Examples: - IBM Deep Blue

Classification based on number of microprocessors


Based on the number of microprocessors, computers can be classified into
Sequential computers and
Parallel computers
a) Sequential computers: - Any task complete in sequential computers is with one
microcomputer only. Most of the computers (today) we see are sequential computers where
in any task is completed sequentially instruction after instruction from the beginning to the
end.

b) Parallel computers: - The parallel computer is relatively fast. New types of


computers that use a large number of processors. The processors perform different tasks
independently and simultaneously thus improving the speed of execution of complex
programs dramatically. Parallel computers match the speed of supercomputers at a fraction of
the cost.

Classification based on word-length


A binary digit is called “BIT”. A word is a group of bits which is fixed for a
computer. The number of bits in a word (or word length) determines the representation of all
characters in these many bits. This is classified into
a) 16 bits computer: is a computer hardware device or software program capable of
transferring 16 bits of data at a time.
b) 32 bits computer: is a computer hardware device or software program capable of
transferring 32 bits of data at a time.
c) 64 bits computer: is a computer hardware device or software program capable of
transferring 64 bits of data at a time.

Classification based on number of users


Based on number of users, computers are classified into: -

a) Single User: - Only one user can use the resource at any time.
b) Multi User: - A single computer shared by a number of users at any time.
c) Network: - A number of interconnected autonomous computers shared by a number
of users at any time.

1.7 Computer Viruses


A computer virus is a a piece of code which is capable of copying itself and typically has a
detrimental effect, such as corrupting the system or destroying data. It is a small piece of
software that piggybacks on real programs. For example, a virus might attach itself to a
program such as a spreadsheet program. Each time the spreadsheet program runs, the virus
runs, too, and it has the chance to reproduce (by attaching to other programs) or wreak havoc.

Types Computer Viruses


(a) Trojan horse: A Trojan horse, or Trojan, is a type of malicious code or software that looks
legitimate but can take control of your computer. A Trojan is designed to damage, disrupt,
steal, or in general inflict some other harmful action on your data or network. A Trojan acts
like a bona fide application or file to trick you. It seeks to deceive you into loading and
executing the malware on your device. Once installed, a Trojan can perform the action it was
designed for. It requires Windows to work and once infected, runs in the background. Some
common type of Trojan malwares are Backdoor, Distributed Denial Of Service (DDOS),
Fake AV, Game- Thief etc
(b) Worm: A worm is a small piece of software that uses computer networks and security holes
to replicate itself. A copy of the worm scans the network for another machine that has a
specific security hole. It copies itself to the new machine using the security hole, and then
starts replicating from there, as well. Examples are The ILOVEYOU, Michelangelo, and
MSBlast worms.
(c) Macro: A macro virus is a computer virus written in the same macro language used for
software programs, including Microsoft Excel or word processors such as Microsoft Word.
When a macro virus infects a software application, it causes a sequence of actions to begin
automatically when the application is. Examples are Concept, Melissa virus etc.
(d) E-mail viruses: An e-mail virus travels as an attachment to e-mail messages, and usually
replicates itself by automatically mailing itself to dozens of people in the victim's e-mail
address book. Some e-mail viruses don't even require a double click, they launch when you
view the infected message in the preview pane of your e-mail software. Example is hoax
email messages etc.

What are some tips to avoid viruses and lessen their impact?
(a) Install anti-virus software from a reputable vendor. Update it and use it regularly.
(b) In addition to scanning for viruses on a regular basis, install an "on access" scanner
(included in most anti-virus software packages) and configure it to start each time you
start up your computer. This will protect your system by checking for viruses each time
you run an executable file.
(c) Use a virus scan before you open any new programs or files that may contain executable
code. This includes packaged software that you buy from the store as well as any
program you might download from the Internet.
(d) If you are a member of an online community or chat room, be very careful about
accepting files or clicking links that you find or that people send you within the
community.
(e) Make sure you back up your data (documents, bookmark files, important email
messages, etc.) on disc so that in the event of a virus infection, you do not lose valuable
work.
Antivirus Software
Antivirus software or Vaccines is a computer program that detects, prevents, and takes
action to disarm or remove malicious software programs, such as viruses and worms.
New viruses, worms, and other threats are created by cyber terrorists and discovered
every day. So updating antivirus software is periodically mandatory. List of some
examples of Anti Virus Programs are:
(a) Norton Antivirus: Norton Antivirus is the most popular and secure virus scanner for
checking boot sector records at start-up. The live update feature automatically installs
new updates for regular protection against viruses.
(b) AVG Free Edition – AVG Resident Shield provides real-time protection executions
of files and programs. It features a smart e-mail scanner, virus updates and virus vault
for secure handling of the files which are infected by viruses. The base version for
windows is Free for private and non-commercial use.
(c) McAfee VirusScan for Windows: This antivirus package detects all virus types,
including Word and Excel macros; boot-sector infections; and file, multipartite,
stealth, polymorphic, and encrypted viruses.
(d) Kaspersky Anti-Virus Personal Pro – It is a commonly used virus protection solution
offering full protection against macro- viruses and unknown viruses.
(e) ESET NOD32 Antivirus – ESET NOD32 Anti-virus is available as an anti-virus for
small businesses, individuals and for large networks.
(f) Avast! Home Edition – A free antivirus solution for scanning disk, CDs, and E-mail.
(g) Panda Antivirus Platinum – It is a complete virus protection package for home and
business users. It comes with an easy installation and automatic protection from latest
viruses.
(h) Avira - Windows and Linux antivirus, firewall, anti spam, recovery solutions against
malware infection

1.8 Roles of Information Processing in Society


Computers have become important tools in our day-to-day’s operations. Some of the areas
computers are used are in:
(a) Engineering: In engineering computers are used for designing using computer aided
design (CAD) software. Modelling and testing processes etc. In Biosystems,
engineering, computers are being used for biometric analysis, genetic engineering
and cloning etc. Space exploration would hardly be impossible without the assistance
of computers.
(b) Manufacturing: Computers have made industrial processes more efficient through
optimization scheduling, process control, and using robots to perform automated
manufacturing process control which are otherwise dangerous to human beings.
(c) Communication: The integration of computers and communication technologies is
what is being referred to as ICT. This merger has resulted to more efficient
communication using computers and other handheld devices such as mobile phones
used to facilitate sending and receiving of messages over the internet. Computers also
control many telecommunications equipment.
(d) Education and research: Computers are used in educational institution as teaching aid,
online teaching especially in open and distance learning and to enhance management.
Internet contains a lot of information for researchers, scholars and teachers/lecturers.
(e) Finance: Many people and companies use computers to help manage their finances.
Some use finance software to balance checkbooks, pay bills, track personal income
and expenses, manage investments, and evaluate financial plans. This software
usually includes a variety of online services. For example, computer users can track
investments and do online banking.
(f) Government: A government provides society with direction by making and
administering policies. To pro- vide citizens with up-to-date information; most
government offices have Web sites. People in the United States access government
Web sites to file taxes, apply for permits and licenses, pay parking tickets, buy
stamps, report crimes, apply for financial aid, and renew vehicle registrations and
driver’s licenses. To provide these services, some Web sites require users provide
personal information. Employees of government agencies use computers as part of
their daily routine.

Other application areas are;

 Law enforcement to carry out biometric mapping activities like fingerprint matching
and store forensic information.
 Banking to keep client accounts details and issue cash transaction services at the
Automated Teller Machines (ATM).
CHAPTER TWO

COMPUTER SOFTWARE
2.0 Introduction

The usefulness of the computer depends on the programs that are written to manipulate it. The
physical components of the computer are called the hardware while all the other resources or parts of
the computer that are not hardware, are referred to as the Software. Software are the set of programs
that makes the computer system active. In essence, the software is the set of program or instructions
implemented on either hardware or firmware to make the computer machine usable. A Program is a
series of coded instructions showing the logical steps the computer follows to solve a given problem.
It is generally referred to as the expression of an algorithm using the constructs (rules) of a particular
computer programming language.

2.1 Computer Software


Computer software can be broadly classified into two groups as shown in figure 2.1:
 System Software
 Application software
Computer Software

Application Software System Software Operating System

Utility Software
User Application Software
Language Translator
Application Packages
Library Programs

Figure 2.1 Computer Software Classifications

2.2 Application Software


Application Software consists of the programs for performing tasks particular to the machine’s
utilization. Application Software is designed to allow the user performs specific tasks that solve
problems in the “real world”. Examples of application software include spreadsheets, database
management systems, Microsoft Word and Several other Microsoft products, accounting systems,
games, Media Players etc. Application Software is accessible and user friendly, process the required
transactions very quickly and accurately.

2.2.1 Types of Application Software


Application software is divided into two namely; User application software and Application
Packages.
i) User Application Software: These are user-written software that are tailored to meet
user’s specific needs. This includes spread sheet templates, word processor macros,
scientific stimulations, graphics, and animation scripts. Users create this software
themselves and often overlook how important it is.
ii) Application Packages: This is when multiple applications are bundled together as one
package. It is also known as ‘application suite’. Examples are Microsoft office, Open
office.org, a spread sheet and several other discrete applications. The separate
applications in a suite usually have some capabilities to interact with each other in ways
beneficial to the user.

2.2.2 Categories Application Package


We have two categories of Application Packages namely; General Purpose Application Package and
Special Purpose Application Package.
i) General Purpose Application Package: A general-purpose application package is a type
of software that can perform many different related tasks. This type of software is
sometimes called generic software.
Common types of general purpose software are:

(a) Word processing software: The main purpose of this software is to produce
documents. MS-Word, Word Pad, Notepad and some other text editors are some of
the examples of word processing software.
(b) Database software: Database is a collection of related data. The purpose of this
software is to organize and manage data. The advantage of this software is that you
can change way data is stored and displayed. MS access, dBase, FoxPro, Paradox, and
Oracle are some of the examples of database software.
(c) Spreadsheet software: The spread sheet software is used to maintain budget, financial
statements, grade sheets, and sales records. The purpose of this software is organizing
numbers. It also allows the users to perform simple or complex calculations on the
numbers entered in rows and columns. Example is Microsoft Excel etc.
(d) Presentation software: This software is used to display the information in the form of
slide show. The three main functions of presentation software is editing that allows
insertion and formatting of text, including graphics in the text and executing the slide
shows. The best example for this type of application software is Microsoft
PowerPoint.
(e) Multimedia software: Media players and real players are the examples of multimedia
software. This software will allow the user to create audio and videos. The different
forms of multimedia software are audio converters, players, burners, video encoders
and decoders.
(f) Web page editors : e.g. MS FrontPage, Macromedia Dreamweaver) are used to create
Web pages
ii) Special Purpose Software Application Package: This software package performs a
single very specific type of task. Examples are Hospital Management system, Human
Resources Management, Reservation Systems, Attendance system, and Billing

2.2.3 Uses of Computer Applications


In this section, different computer applications and their uses are discussed.
 Online Application
 Real Time Application
 Business Application
a) Online Applications
Today, most of the applications are being accepted online, whether it is for opening a bank account,
filling admission form, filling job application, etc. Following are the important forms of online
applications:
i) Banking: Most of the banks are interlinked through computer networking and offer core
banking facilities. Computer networking helps maintain accounts online, offers net
banking facility, makes available online transactions facility, and offers digital signature
facility, the biggest advantage being that ATM machines can dispense money anytime,
etc.
ii) Ticket Booking: Ticket booking has become easier with computer networking. Flight
ticket, railway ticket, and even bus ticket can be booked online with simple and easy
steps.
iii) Passport Application: If you want to apply for a new passport, you can do it by yourself
online. Besides, you can also apply for other essential documents online such as PAN
card, Aadhaar Card, etc.
iv) Job Application: Today, most of the applications (private as well as government) are
being filled online. Many of the organizations also conduct competitive exams leading to
employment online.
v) Admission Application: Most of the schools and universities have made their admission
applications available online; they also accept fees online.
b) Real-time Application
Real-time application is a computer based application program that functions in a given period of
time or in other words, in a given period of time, a user has to perform certain functions before the
time lapses. For example, if you are making online transactions, then you have to provide the
required information in a given time framework or else you will miss the chance. Following are
significant examples of real-time application:
i) Videoconferencing: With this technology, people can connect with each other visually
from different places. VoIP (voice over Internet Protocol). This technology helps to make
telephone calls over digital computer networks.
ii) E-commerce transactions: This technology helps in buying and selling products over the
digital computer network.
iii) Online banking: Online banking is virtual banking from any place with the help of
computer networks.
iv) Instant messaging: This is where messages can be exchanged over the Internet instantly.
v) Online gaming: This enables playing of games partially or completely over the Internet.
c) Business Application
Different businesses have different computer applications; however, a few applications such as for
maintaining the data base (of respective business), keeping employees’ records, offering online
business facilities, online promotions, etc. are the common features of almost every business
organization.

2.3 System Software


These are set of software that acts as interface between the computer resources and the users. This
refers to the suits of programs that facilitates the optimal use of the hardware systems and/or provide
a suitable environment for the writing, editing, debugging, testing and running of User Programs.
Usually, every computer system comes with collection of these suits of programs which are provided
by the Hardware Manufacturer. Systems programs are programs written for direct execution on
computer hardware in order to make the power of the computer fully and efficiently accessible to
applications programmers and other computer users. Systems programming is different from
application programming because it requires an intimate knowledge of the computer hardware as
well as the end users’ needs. Moreover, systems programs are often large and more complex than
application programs, although that is not always the case. Since systems programs provide the
foundation upon which application programs are built, it is most important that systems programs are
reliable, efficient and correct.
Functions of System Software are:
i) It enhances the running of user programs
ii) It maximizes the performance of the computer system
iii) It provides necessary support needed for application program development.
iv) It makes the use of the computer system simple.

2.3.1 Classification of System Software


System Software can be classified as follows;
 Operating systems
 Utility softwares
 Language translators
 Library Programs
2.3.2 Operating Systems

An operating system (OS) is the software that manages computer hardware and software resources
and provides common services for computer programs. It can also be defined as a layer of software
that provides access to the computer resources and creates an environment with which application
programs can run. Application programs rely on the facilities provided by the operating system to
gain access to the computer system resources such as files, memory, CPU, input/output devices e.t.c.
Users usually interact with the Operating System directly by means of Operating System commands.
Programs also invoked the services of Operating System by means of Operating System calls.
Internally, operating systems vary greatly in their makeup, since they are organized along many
different lines. The design of a new operating system is a major task. It is important that the goals of
the system be well defined before the design begins. These goals form the basis for choices among
various algorithms and strategies. Because an operating system is large and complex, it must be
created piece by piece. Each of these pieces should be a well delineated portion of the system, with
carefully defined inputs, outputs, and functions. Operating system can be thought of as having three
objectives namely:
 Convenience: An OS makes a computer more convenient to use (i.e. it serves as interface).
 Efficiency: An OS allows the computer system resources to be used in an efficient manner (it
manages computer system resources).
 Ability to evolve: An OS was constructed in such a way as to permit the effective
development, testing, and introduction of new system functions without interfering with service.

Three Major Functions of Operating System


i) The Operating System as a User/Computer Interface
The hardware and software used in providing applications to a user can be viewed in a layered or
hierarchical fashion as reflected in figure 2.2. The user of those applications, the end user, generally
is not concerned with the details of computer hardware. The most important collection of system
programs comprises the Operating System (OS). The OS hides the details of the hardware from the
programmer and provides the programmer with a convenient interface for using the system. It acts as
mediator, making it easier for the programmer and for application programs to access and use those
facilities and services.

Figure 2.2: Computer Hardware and Software Structure

Operating System provides the following services as an interface


 Program development: The OS provides a variety of facilities and services, such as editors
and debuggers, to assist the programmer in creating programs. Typically, these services
are in the form of utility programs that, while not strictly part of the core of the OS, are
supplied with the OS and are referred to as application program development tools.
 Program execution: A number of steps need to be performed to execute a program.
Instructions and data must be loaded into main memory, I/O devices and files must be
initialized, and other resources must be prepared. The OS handles these scheduling duties
for the user.
 Access to I/O devices: Each I/O device requires its own peculiar set of instructions or
control signals for operation. The OS provides a uniform interface that hides these details
so that programmers can access such devices using simple reads and writes.
 Controlled access to files: For file access, the OS must reflect a detailed understanding of
not only the nature of the I/O device (disk drive, tape drive) but also the structure of the
data contained in the files on the storage medium. In the case of a system with multiple
users, the OS may provide protection mechanisms to control access to the files.
 System access: For shared or public systems, the OS controls access to the system as a
whole and to specific system resources. The access function must provide protection of
resources and data from unauthorized users and must resolve conflicts for resource
contention.
 Error detection and response: A variety of errors can occur while a computer system is
running. These include internal and external hardware errors, such as a memory error, or a
device failure or malfunction; and various software errors, such as division by zero,
attempt to access forbidden memory location, and inability of the OS to grant the request
of an application. In each case, the OS must provide a response that clears the error
condition with the least impact on running applications. The response may range from
ending the program that caused the error, to retrying the operation, to simply reporting the
error to the application.
 Accounting: A good OS will collect usage statistics for various resources and monitor
performance parameters such as response time. On any system, this information is useful
in anticipating the need for future enhancements and in tuning the system to improve
performance. On a multiuser system, the information can be used for billing purposes.

ii) The Operating System as Resource Manager


A computer is a set of resources for the movement, storage, and processing of data and for the
control of these functions. The OS is responsible for managing these resources. Can we say that it is
the OS that controls the movement, storage, and processing of data? From one point of view, the
answer is yes: By managing the computer’s resources, the OS is in control of the computer’s basic
functions. But this control is exercised in a curious way.
Like other computer programs, the OS provides instructions for the processor. The key difference is
in the intent of the program. The OS directs the processor in the use of the other system resources
and in the timing of its execution of other programs. But in order for the processor to do any of these
things, it must cease executing the OS program and execute other programs. Thus, the OS
relinquishes control for the processor to do some “useful” work and then resumes control long
enough to prepare the processor to do the next piece of work.

iii) Operating System makes possible ease of evolution


A major OS will evolve over time for a number of reasons:
 Hardware upgrades plus new types of hardware:
 New services:
 Fixes:
2.3.2.1 Evolution and Types of Operating Systems
In attempting to understand the key requirements for an OS and the significance of the major features
of a contemporary OS, it is useful to consider how operating systems have evolved over the years.
(i) Serial Processing : With the earliest computers, from the late 1940s to the mid-1950s, the
programmer interacted directly with the computer hardware; there was no OS. These computers were
run from a console consisting of display lights, toggle switches, some form of input device, and a
printer. Programs in machine code were loaded via the input device (e.g., a card reader). If an error
halted the program, the error condition was indicated by the lights. If the program proceeded to a
normal completion, the output appeared on the printer.
These early systems presented two main problems:
 Scheduling: Most installations used a hardcopy sign-up sheet to reserve computer time.
Typically, a user could sign up for a block of time in multiples of a half hour or so. A user
might sign up for an hour and finish in 45 minutes; this would result in wasted computer
processing time. On the other hand, the user might run into problems, not finish in the
allotted time, and be forced to stop before resolving the problem.
 Setup time: A single program, called a job, could involve loading the compiler plus the high-
level language program (source program) into memory, saving the compiled program (object
program) and then loading and linking together the object program and common functions.
Each of these steps could involve mounting or dismounting tapes or setting up card decks. If
an error occurred, the hapless user typically had to go back to the beginning of the setup
sequence. Thus, a considerable amount of time was spent just in setting up the program to
run. This mode of operation could be termed serial processing, reflecting the fact that users
have access to the computer in series. Over time, various system software tools were
developed to attempt to make serial processing more efficient. These include libraries of
common functions, linkers, loaders, debuggers, and I/O driver routines that were available as
common software for all users.
(ii) Simple Batch Operating Systems: Early computers were very expensive, and therefore it was
important to maximize processor utilization. The wasted time due to scheduling and setup time was
unacceptable. To improve utilization, the concept of a batch OS was developed. It appears that the
first batch OS (and the first OS of any kind) was developed in the mid-1950s by General Motors for
use on an IBM 701.
(iii) Multiprogrammed Batch Operating Systems: Even with the automatic job sequencing
provided by a simple batch OS, the processor is often idle. The problem is that I/O devices are slow
compared to the processor. The processor spends a certain amount of time executing, until it reaches
an I/O instruction. It must then wait until that I/O instruction concludes before proceeding.
(iv) Time-Sharing Operating Systems: With the use of multiprogramming, batch processing can
be quite efficient. However, for many jobs, it is desirable to provide a mode in which the user
interacts directly with the computer. Indeed, for some jobs, such as transaction processing, an
interactive mode is essential.
(v) Network Operating System Network Operating System runs on a server and and provides
server the capability to manage data, users, groups, security, applications, and other networking
functions. The primary purpose of the network operating system is to allow shared file and printer
access among multiple computers in a network, typically a local area network (LAN), a private
network or to other networks. Examples of network operating systems are Microsoft Windows
Server 2003, Microsoft Windows Server 2008, UNIX, Linux, Mac OS X, Novell NetWare, and
BSD.
(vi) Real time system: Real time system is defines as a data processing system in which the time
interval required to process and respond to inputs is so small that it controls the environment. Real
time processing is always on line whereas on line system need not be real time. The time taken by
the system to respond to an input and display of required updated information is termed as response
time. So in this method response time is very less as compared to the online processing.
There are two types of real-time operating systems.
a) Hard real-time systems: Hard real-time systems guarantee that critical tasks complete on
time. In hard real-time systems secondary storage is limited or missing with data stored in
ROM. In these systems virtual memory is almost never found.
b) Soft real-time systems: Soft real time systems are less restrictive. Critical real-time task gets
priority over other tasks and retains the priority until it completes. Soft real-time systems
have limited utility than hard real- time systems. For example, Multimedia, virtual reality,
Advanced Scientific Projects like undersea exploration and planetary rovers etc.

2.3.2.2 Components of Operating Systems


The Operating System is actually composed of subsystems, each of which controls distinct categories
of computer system resources, these include: File management, Secondary storage management, I/O
system management, Networking, Protection system and Command interpreter system.
a) Process Management: A program does nothing unless its instructions are executed by a CPU.
A process in operating system is the smallest individually scheduableable entity consisting of
codes and data and is characterized by attributes and dynamic state.
b) Main Memory Management: The needs of users can be met best by a computing environment
that supports modular programming and the flexible use of data. System managers need
efficient and orderly control of storage allocation. For OS to satisfy these requirements, it has
five principal storage management responsibilities:
i) Process isolation: The OS must prevent independent processes from interfering
with each other’s memory, both data and instructions.
ii) Automatic allocation and management: Programs should be dynamically allocated
across the memory hierarchy as required. Allocation should be transparent to the
programmer.
iii) Support of modular programming: Programmers should be able to define program
modules, and to create, destroy, and alter the size of modules dynamically.
iv) Protection and access control: Sharing of memory, at any level of the memory
hierarchy creates the potential for one program to address the memory space of
another. This is desirable when sharing is needed by particular applications.
v) Long-term storage: Many application programs require means for storing
information for extended periods of time, after the computer has been powered down.
Typically, operating systems meet these requirements with virtual memory and file
system facilities. The file system implements a long-term store, with information stored in
named objects, called files. The file is a convenient concept for the programmer and is a
useful unit of access control and protection for the OS.
c) File Management: File management is one of the most visible components of an operating
system. Computers can store information on several different types of physical media:
Magnetic disk, optical disk, and magnetic tape are the most common. Each of these media
has its own characteristics and physical organization. Each medium is controlled by a device,
such as a disk drive or tape drive, that also has its own unique characteristics. These
properties include access speed, capacity, data-transfer rate, and access method (sequential or
random).
d) Information Protection and Security: The growth in the use of time-sharing systems and more
recently computer networks has brought with it a growth in concern for the protection of
information. However, there are some general-purpose tools that can be built into computers
and operating systems that support a variety of protection and security mechanisms. In
general, we are concerned with the problem of controlling access to computer systems and
the information stored in them. Much of the work in security and protection as it relates to
operating systems can be roughly grouped into four categories:
o Availability: Concerned with protecting the system against interruption.
o Confidentiality: Assures that users cannot read data for which access is
unauthorized.
o Data integrity: Protection of data from unauthorized modification.
o Authenticity: Concerned with the proper verification of the identity of users and the
validity of messages or data.

2.4 Utility Software


This is a set of commonly used programs in data processing departments also called service or
general-purpose programs. The majority of an installation’s utility software consists of programs for
performing activities that are fundamental to computer installations but not included in the operating
system. In a sense, utility software consists of software units that extend (or perhaps customize) the
capabilities of the operating system. For example, the ability to format a magnetic disk or to copy a
file from a magnetic disk to a CD is often not implemented within the operating system itself but
instead is provided by means of a utility program. Other instances of utility software include
software to compress and decompress data, software for playing multimedia presentations, and
software for handling network communication. Implementing certain activities as utility software
allows system software to be customized to the needs of a particular installation more easily than if
they were included in the operating system. They perform the following operations.
a) File Conversion: This covers data transfer from any medium to another, making an exact
copy or simultaneously editing and validating. For example, copying from a hard disk to a
diskette or a flash.
b) File Copy: It makes an exact copy of a file from one medium to another or from an area of a
medium to another area of the same medium.
c) Housekeeping Operations: These include programs to clear areas of storage, writing file
labels and updating common data. They are not involved in solving the problem at hand.
They are operations that must be performed before and after actual processing.
.
2.5 Language Translators
A programming language is a set of notations in which we express our instructions to the computer.
At the initial stage of computer development, programs were written in machine language
conducting the binary system i.e. 0 and 1. Such programs were hard to write, read, debug and
maintain. In an attempt to solve these problems, other computer languages were developed.
However, computers can run programs written only in machine language. There is therefore the need
to translate programs written in these other languages to machine language. The suites of languages
that translate other languages to machine language are called Language Translator. The initial
program written in a language different from machine language is called the source program and its
equivalent in machine language is called object program.
Examples of classes of language translators are:
i) Assemblers: An Assembler is a computer program that accepts a source program in assembly
language and translates the entire program into an equivalent program in machine language called
the object program or object code. Each machine has its own assembly language, meaning that the
assembly language of one machine cannot run on another machine.
Programmers found it difficult to write or red programs in machine language. In a quest for a
convenient language, they began to use a mnemonic (symbol) for each machine instructions which
would subsequently be translated into machine language, such a mnemonic language is called
Assembly language. Examples of Assembler are; IBM ALP, MAC/65, A86/A386
ii) Interpreter: An Interpreter is a program that accepts program from a source language, reads,
translates and executes it line by line into machine language. The interpreter reads the source
program and stores it in memory. · During interpretation, it takes a source statement, determines its
meaning and performs actions which increments it. This includes computational and I/O actions. ·
Program counter (PC) indicates which statement of the source program is to be interpreted next. This
statement would be subjected to the interpretation cycle. The interpretation cycle consists of the
following steps:
i. Fetch the statement.
ii. Analyze the statement and determine its meaning.
iii. Execute the meaning of the statement.
Examples of Interpreter are Python , LISP, Ocamle.

iii) Compilers: A Compiler is a computer program that accepts a source program in one high-
level language, reads and translates the entire user’s program into an equivalent program in machine
language, called the object program or object code. The stages in compilation include:
a) Lexical analysis
b) Syntax analysis
c) Semantic analysis
d) Code generation
For each high-level language, there are different compilers. We can therefore talk of COBOL
Compilers, FORTRAN Compilers, BASIC Compilers, etc. A Compiler also detects syntax errors,
errors that arise from the use of the language. Compilers are portable i.e. a COBOL Compiler on one
machine can run on a different machine with minimum changes. Examples of Compiler are; C, C++,
Java, Microsoft Visual Studio.

2.6 Library Programs


Library programs are compiled libraries of commonly-used routines. On a Windows system they
carry the file extension dll and are often referred to as run-time libraries. The libraries are run-time
because they are called upon by running programs when they are needed. When you program using a
run-time library, you typically add a reference to it either in your code or through the IDE in which
you are programming. Some library programs are provided within operating systems like Windows
or along with development tools like Visual Studio. For example, it is possible to download and use
a library of routines that can be used with Windows Media Player. This includes things like making
playlists, functions and procedures for accessing and manipulating the music library (which is a
binary file) and playback routines. Using library programs saves time when programming. It also
allows the programmer to interact with proprietary software without having access to its source code.
CHAPTER THREE

COMPUTER HARDWARE
.
3.1 The System Unit
The system unit is the main unit of a PC. It is the Computer itself while other units attached to it are
regarded as peripherals. It could be viewed as the master conductor orchestrating your PC’s
operation. It is made up of several components like the Motherboard, Processor, Buses, memory,
power supply unit, etc. This unit (system unit) has been confused over the years by novices as the
CPU. This is not true. The CPU (Central Processing Unit) or simply processor is a component within
the system unit and it is not the only thing that makes up the system unit. Hence, it will be wrong to
equate the system unit with the CPU.

3.1.1 Front of the System Unit


The front of the system unit consists of the following;
Lights
Your unit may display a variety of colored light on the front panel, including power and turbo
signals, and light to indicate if the Hard or Floppy disk are being read or written to.
Key Lock
You can stop intruders tampering with your PC by using the Lock on the front panel. Turning the key
prevents the key board from working.
Turbo Button
Some PCs offer a choice of speeds at which they can run. A turbo switch is usually left so the
computer runs at its fastest speed.
Reset Button
If your PC “freezes” and won’t respond to any command, try starting it up again using the reset
button. Pressing the reset button loses all the work you have not saved in that session, so use it only
as a last resort.
Power On/Off
All PCs have main power switch on the system unit. Sometimes this control is placed on the outside
back panel.
Floppy Disk Drives
Either, or both, of two standard types of floppy disk drive may be found at the front of the system
unit. Some systems also have internal CD-ROM or tape drives.

1
1.2 Back of the System Unit

The back of the system unit consists of the following;


Fan Housing
The electronic components in your PC generate a lot of heat. To prevent overheating, a fan at the
back of the unit removes hot air from the system.
Power “in” and “out” Sockets
Cables plugged into these sockets carry power from the electrical outlet to the system unit and from
the system unit to the monitor.
Joystick Port
Using a joystick is often much better than pressing keys to control movements when playing a
computer game.
Serial Ports
Serial Ports often connect the PC to modem or mouse. Most PCs are fitted with two serial ports that
may be labeled “S101” and “S102”, “Serial 1” and “Serial 2”, or “COM1” and “COM 2”.
Sound Jacks
If you have a sound fitted inside your system unit, you will see a jack or jacks at the back. These can
be used to connect your PC to speakers, a microphone, or an eternal sound source.
Keyboard Port
The cable from your keyboards ends with a round connector, which plugs into the keyboard port.
Network Adapter
If an expansion card is fitted to link your PC with other PCs in your office you will see a network
connector at the back of the system unit.
Monitor Port
A cable from your monitor plugs into this port and carries display information to the monitor.
Bays for Expansion Cards
PCs are easily expanded-perhaps to provide a modem, sound or faster graphics. You can plug cards
into expansion slots inside the PC. The end of an expansion card shows at the back of your machine,
allowing you to connect items.

3.1.3 Inside the system unit


The brain behind everything that happens in your PC is contained within the system unit. Inside the
unit are the impressive electronics that run programs, handle instructions, and determine the results.
Most of the more important items are described below:

Battery
A small battery powers a clock to keep track of the time when the PC is turned off. It also maintains
low electricity to certain RAM chips that record which components are installed.

Disk Drive Controller Card


This card controls the PC’s disk drive motors and transfers data. The serial and parallel ports at the
back of the card link internal PC components with external devices such as mouse and printer.

Display Adapter Card (Video Card)


All the information your computer will display is stored in its memory. To be useful, you need to see
the information. The display adapter card is the link between the PC’s memory and the monitor.

Expansion Slots
These long narrow connectors allow you to plug in expansion cards (also known as adapter cards),
which offer extra options not available on a basic PC.
2
ROM Chips

Read-only memory (ROM) chips have data written on them during manufacturing that tells the CPU
what to do when the PC is switched on. The data is always there, even when you switch the PC off.

RAM Chips
When a computer is switched on and running a program, RAMS (Random Access Memory) is used
for purposes such as holding the program and its data. But when the PC is switched off, anything
held in RAM is lost.

Empty RAM Chip Slots


These slots let you expand your computer’s memory by adding extra RAM chips or modules. Some
PC’s work even faster because they come equipped with Cache Memory. Cache Memory consists of
expensive and very fast memory chips that store the data or instructions that the CPU will look at
next. Cache memory can speed up
work on your computer enormously.

RAM chip
Central Processing Unit (CPU)

The Microprocessor, or Central Processing Unit (CPU), is the computer’s most important single
item. It does all the PC’s thinking and runs the programs (series of instructions) that you request.

CPU Support Chips


These chips help the CPU manage all the other parts of the computer.

Math Coprocessor Slot


A math coprocessor, present in some PCs, assists the CPU in its number-crunching Activities.

3
Speaker
The speaker emits the computer’s sound output.

Power Supply Unit


All the components in a PC need electrical supply. Most need a 5-volt supply although the floppy
disk drive motors required 12 volts. If the components were connected to normal household current,
they would blow up, so the power supply unit converts high voltage electrical current to a low
voltage.

Hard Disk Drive


The hard disk is your computer’s main permanent storage unit, holding large amount of data and
programs. Unlike data held in RAM, the information on the hard disk is not affected when the PC is
turned off – it remains there unless you instruct the PC to overwrite it or the hard disk is damaged.

Motherboard
All the electronic components in a PC are mounted on a piece of fiberglass called the motherboard.
Fiberglass cannot conduct electricity, so each component is insulated from all the others. Thin lines
of metal on the surface of the fiberglass connect pins from one component to another, forming the
computer’s electrical circuits.

Components of a motherboard
Intel CPUs
The earliest PCs were equipped with a CPU from Intel Corporation called the 8088. The next
generation of PCs used CPU known by the number “80286 and were called “PC/AT” computers.
Subsequently, PCs have been supplied with more and more powerful CPUs – the 80386, the 80486,
and the more recent and impressive of all, the Intel Pentium (I, II, III, IV& M).
All these PC processors belong to a family called 80 x 86. In general, you can run the same software
on PCs containing different CPUs within this family. From the outside, the chips look different only
in sizes and number of pin-put inside, an 80486 has over one million components to the 3,500 that
were in the first 8088. Because of these differences, the latest Pentiums runs over ten times faster.

What is CPU
The CPU is certainly the most important PC component. CPU stands for Central Processing Unit.
Let us briefly study that name:
 ı It is a processor, because it processes (moves and calculates) data.
 ı It is central, because it is the center of PC data processing.
 ı It is a unit, because it is a chip, which contains millions of transistors.

CPU Speed
The speed of a CPU is measured in megahertz (MHz). A computer has central clock that keeps all
the components in time with each other; one hertz is similar to a clock tick and megahertz is equal to
one million ticks per second. If your PC runs at 333 or 400MHz,the central clock ticks 333 or 400
million times every second. As you might imagine, the faster the clock ticks, the faster the computer
runs. Without the CPU, there would be no PC. Like all other hardware components, the CPUs are
continually undergoing further development. You can see the explosive technological development
in data processing most clearly in the development of newer and faster CPUs. The CPUs have for
years doubled their performance about every 18 months and there are no indications that this trend
will stop.

4
When we now look at all the CPUs from a broader perspective, we can see that:
 The CPU history is closely tied to the companies IBM and especially Intel.
 The CPUs have their roots back to Intel's chip 4004 from 1971.
 The compatibility concept has been important throughout the development.

DISKS

Floppy Disks
Computers use disk to store information. Although there is a permanent hard disk that lives inside the
system unit, you can use floppy disks to store and move data easily from one PC to another. Floppy
disks come in two sizes, either 5¼ or 3½ inches in diameter.

The smaller disks are able to store more data and are also less easily damaged, because of their
thicker plastic cases. As both sizes can be either “high” or “low” capacity (or density), there are four
main varieties of disks available. High-capacity disks are more expensive, but they can store much
more information. Low-capacity disks are generally labeled DS/DD, which stands for “double
sided/double density”, while the high-capacity floppy disks are labeled DS/HD (double sided/high-
density”).

Caring for Disks


Treat floppy disks carefully, and you can take them almost anywhere safely. Don’t leave the disks in
your PC when you finish a session. Also avoid putting anything heavy on topof your disks or leaving
them in extremes of hot or cold temperature. Try not to carry disks loose in pockets or handbags
where dust and dirt may get inside the containers.

Take care to store them vertically, preferably in a special storage box. Remember too that you should
keep floppy disks away from magnetic fields, including hidden magnets such as those in telephone,
radio and television speakers, amplifiers, desk fans, and photocopiers. If you do leave floppy disks
near magnetic field, your data may become corrupted and will no longer be usable.

Write Protecting Disks


Write – protecting a disk means that you prevent the computer from erasing or writing over
important data or programs that are already there. However, the PC can still read a write-protected
disk.

PERIPHERAL DEVICES
The computer peripheral devices are those devices which are attached to the system unit. The devices
are necessary to ensure that the computer is able to accept input and display the result for the user.
This section therefore discusses the input unit and the output unit.

Input Devices

1 Computer Keyboard
A Computer keyboard is identical to the conventional typewriter keyboard. However, it has more
keys than the typewriter keyboard. A computer keyboard can be a dummy type or intelligent type. A
computer keyboard is considered too be intelligent if, in addition to performing the routine functions
characteristic of a typewriter keyboard, it can initiate a series of actions for a computer to carry out
by mere pressing a key or combination of

5
two or more keys. An intelligent computer keyboard has a set of keys and when one of them is
pressed, the computer can be made to carry out a specific function. For example, the pressing of a
key may cause the computer to display a menu list from which a human being may be prompted to
select one.

The intelligent computer keyboard has four major divisions, namely: Function keys, Alphanumeric
keys, Numeric keys and Control keys. In addition to the four types of keys, there are some special or
important keys such as the following:
(a) Return or Enter key
(b) Escape key denoted by ESC
(c) Control key denoted by CTRL
(d) Alternate key denoted by ALT
(e) Delete key denoted by DEL
(f) Insert key denoted by INS
(g) Backspace key
(h) Shift key.

Function Keys
The effects of the functions keys are software package dependent. That is, they mean different
translations depending on which software package one is running on the computer. The function keys
are traditionally labeled F1, F2, F3, F4, F5, F6, F7, F8, F9, F10, F11 and F12. The function keys are
often arranged to the left of the main keyboard in two columns or they are arranged in a row above
the main keyboard. In most software
packages, the function key F1 is used to run the HELP program. Word perfect, for example, uses F3
for HELP program and F1 to cancel the last command issued on the computer. The function keys F7
and F12 are used to save a text and block a section of a text respectively in word perfect. Function
keys can be programmed to carry out the functions desired by a programmer. For example the
function keys F10 may be programmed to display menus. Thus, the operations of the function keys
can be determined by the user or programmed by the software package being used at any point in
time.
Alphanumeric Keys
The Alphanumeric keys can be likened with the conventional typewriter keys. They contain
alphabetic characters, numeric characters and special characters such as comma, full stop, open
bracket, close bracket, asterisk, semicolon, colon, question mark, and soon. Usually, each key carries
a character at the lower part and another character at the upper part. The SHIFT key is used to switch
on or off the lower and upper characters by
the programmer.

Cursor Control Keys


The cursor marks the active or current spot on the screen. It is an indicator that tells the user where in
the midst of a document the system is pointing to. It may be a rectangular bar of light or a blinking
underscore. When a text is being typed, the cursor moves as the carriage on a keyboard moves and
character are typed in. The cursor control keys include four directional arrow keys.

6
Other cursor control keys are HOME, PAGE UP, PAGE DOWN, and END. These keys may be part
of the numeric keypad or separated from the numeric keypad. Moving the cursor around on the
screen is one of the most common tasks in an application program.

In fact, cursor movement is so important in an application such as word processing that it can usually
be accomplished by additional key-driven commands. The control keys and their functions are
documented in Table the above table.

Numeric Keypad
The numeric keypad contains a set of keys required for typing or entering number digits0, 1, 2, 3, 4,
5, 6, 7, 8, and 9 into the computer store. A numeric key is often activated by pressing the Numlock
Key. The numeric keypad is also used in combination with Alternate (Alt) key to produced extended
characters. Extended characters are characters not normally found on most keyboard. For example, to
produced the character alpha data denoted one holds down the Alt key and press 224; to produce
character beta data denoted by one holds down the Alt key and press 255 and to produce pound
sterling denoted by ‘₤’, one holds down the Alt key and press 156.

Shift Key
When the Shift key is pressed, the capital letters on the alphanumeric keys are activated. It also
serves as the activator of characters that are at the upper part of each alphanumeric key. The Shift
key has no effects on itself; its effect are realized when some other keys are pressed. Thus, if one
presses the shift key and then ‘equal’ sign key, the ‘plus’ sign which is at the upper part of the
‘equal’ sign is activated and then it appears on the screen.

CapLock Key
The CapLock Shifts all alphabetic characters into upper case (capital letters). Thus all characters
typed are in lower case (small letters) when not pressed.
7
Alternate Key (Alt)
The Alternate key can be used in combination with numeric keys to generate characters not shown on
the keyboard, that is, extended characters. For example, holding the Alt key down and pressing 228
produces the summation ( ) sign; holding the Alt key down and pressing 235 produce sign. To
restart or reboot your computer, press Alt, Ctrl and Delkeys simultaneously.

NumLock Key
The Numlock key activates the numeric keypad. Neither NumLock nor CapLock affects the function
keys.

Control Key (Ctrl)


The Control key is often used in most text mode to perform block operations like mass deletion,
insertion and so on. For example, CTRL + Y deletes a line in most text documents. It can also be
used in combination with other keys to move the cursor to different locations in a text or document.
In some application packages, the Alt, Ctrl and Shift key are used in combination with the function
keys to perform several operations.

For example, in Word Perfect word processing package, to centre a text; press Shift andF6; to print a
text, press Shift and F7.

Escape Key (Esc)


The Escape key cancels an operation in progress. For example, when one is editing a file or issuing a
command, ESC cancels any changes one might have made or terminates the command.

Return or Enter Key


The Return key serves as one of the most important keys on most keyboards. It is actually used to
inform the computer the end of an input or command. It performs two functions depending on the
program with which it is used. For example, suppose you are asked to respond to an operating system
command at the prompt or other entries, the operating system will wait until the return key is pressed
before continuing. Pressing the return key
also positions the cursor at the beginning of the next line ( in text mode), which is the equivalent of
pressing the carriage return on a typewriter.

Insert Key (Ins)


Pressing the Insert key puts ones keyboard in insert mode, pressing it again returns to overstrike
(type over) mode. In insert mode, the characters one types are inserted at the cursor position, the
character at the cursor position and all characters to the right, shift to make room for them. In
overstrike or type over mode, newly typed characters over write the characters at the current cursor
position. In most application software insert mode is indicated by a symbol in the status line.

Delete Key (Del)


The delete key deletes the character at the cursor position when pressed and the remaining text
moves to the left while the cursor remains at the same position.

Back Space Key


The Back Space Key deletes the characters to the left of the cursor when pressed and all other
characters to the right of the cursor are shifted one space to the left.

8
Spacebar
The Spacebar is the longest key found on most keyboards. It erases characters at the cursor position
or gives blank space when pressed.
Tab Key
The Tab Key moves the cursor by five spaces to the right when pressed. The number of positions
moved depend on the software or the Tab Set by the operator. The Tab is normally pressed to insert
paragraphs during typing. In some programs, when this key is pressed in combination with shift key,
the same number of positions is moved backwards.

Print Screen Key (Prtsc)


When the Print Screen key is pressed in combination with the Shift Key, whatever is on the screen
will be printed on a printer. The same effect can be achieved by pressing the key alone on some
keyboards.

Keeping Your Keyboard Clean and Working


Never spill liquids on your keyboard. Coffee, soda, and other beverage spills can ruin your keyboard.
Liquid spills on the keyboard have even been known to cause electrical damage to the PC itself. With
that in mind, though you may not stop drinking coffee around your computer, you should at least get
a spill-proof mug or keep the coffee on the other side of the desk.
Another enemy of keyboards is static electricity. Static electricity can have the same damaging effect
on your keyboard as does liquid. If your keyboard doesn't respond properly after a strong static
charge, you may just need to turn off the PC and turn it back on to reset the keyboard. In some cases,
however, the static discharge can zap the keyboard and even parts of the PC. If you shuffle your feet
across carpet or your PC is in a room with dry air, avoid touching the PC or the keyboard until you
have touched something metal to discharge any static. If you don't have a metal desk or bookcase in
your work area, consider buying an anti-static mat and keeping it where you can touch it before
touching the PC.
Dust, dirt, food crumbs, and hair are other enemies of keyboards. Try to avoid eating over the
keyboard and if your computer is in a dirty, dusty area, keep the keyboard covered when not in use.
Some dirt and dust is unavoidable. To keep the keyboard working well, you should occasionally
clean it.

2 Mouse and Joystick


A mouse looks like the electrical clipper in a barbing saloon. It consists of a pointing device very
sensitive to movements. It has a roller ball and two or more buttons which can be pressed to make
selection. By moving the mouse on a flat smooth surface and clicking one or combination of two
buttons on its upper surface, a computer to which it is connected can be sensitized and commanded to
carry out some specific tasks.

A mouse can be used to draw diagrams on computer screen more effectively and efficiently than the
computer keyboard. Generally, the keyboard and the mouse do complement each other. For example,
the mouse can be used to highlight an item in a menu list while the keyboard Enter Key can be
pressed to activate or evoke the command associated with the highlighted item.

A mouse is the primary input device for modern computers that feature operating systems with a
graphical user interface, such as Windows 98 or Windows XP. While keyboards obviously excel at
entering text, numbers, and symbols, your mouse is the tool you'll use to tell your computer what to
do with all the data you've entered.

9
Joysticks are almost exclusively used with game software and help the user more effectively control
the actions of computer-simulated airplanes or arcade-style games. All modern PC operating systems
(Windows 98, Windows XP, and the Macintosh) rely on an on-screen pointer to select and execute
commands. A mouse is simply an input device built to help the user control this on-screen pointer in
as natural and efficient a manner as possible.

The pointer on the screen mimics the movements of your mouse. As you move your mouse, a ball
encased in the bottom of your mouse rolls on the desk and in turn sends signals to the computer as to
which direction to move the pointer on the screen. Move the mouse side to side, or up and down, and
the on-screen pointer moves in a similar manner.
Once you have the mouse positioned to select the command or data you want to act on, you use the
mouse buttons to execute the command. The mouse controls the on-screen pointer and lets you select
program icons, manipulate property sheets, and access data.

3. Output Device
1 Printer
A printer is the computer component that lets you create copies of the information stored in your
computer on paper. The printed material is often called hard copy, to differentiate it from the data
stored on a disk, or held in the computer's memory. There are three basic types of printers available
for use with personal computers:

Laser printers. These combine a magnetic roller with powdered ink called toner to transfer high-
quality characters or images onto a page.

Inkjet printers. These have small nozzles that actually spray fast-drying ink onto the page to form
characters or images. Inkjet printers spray a fine, quick-drying ink through small nozzles to produce
characters and images on paper. Although the results are not quite as sharp as those of laser printers,
inkjet printers provide very good quality output ata lower cost.

Dot-matrix printers.
These use a print head to strike an inked ribbon against paper, like a typewriter, creating characters
out of a series of dots. Dot-matrix printers are the cheapest printers available.
They create text and images on the page by hammering several small pins against aninked ribbon.
The more pins used, the better the image--9-pin and 24-pin are common options. The 24-pin printers
produce a better quality output, but are somewhat slower than the 9-pin printers.

Print quality for dot-matrix printers is often described in terms of mode: draft mode (low resolution),
near-letter-quality mode (medium resolution), or letter-quality mode (high resolution). The speed
depends on the mode, with draft mode being the fastest.

The type of printer you choose depends on your budget and the type of output you need. For
example, if all you need to print are grocery lists, you may be happy with a dot-matrix printer. In
general, dot-matrix printers are noisier, slower, and produce a poorer quality image than do laser or
inkjet printers, but they are also less expensive. If you need to print newsletters, brochures, or
illustrated reports, you will probably want a high quality laser printer. Laser printers cost more than
other printers, but they may be worth the price because they are fast, quiet, and produce high-quality
text and graphics.

2 Monitors

10
The monitor does not do any processing itself. The monitor only displays the information that the
video card tells it to.
Monitor Sizes
The two most common monitor sizes are 15-inch and 17-inch. If you have an older, hand me down
PC or a very inexpensive starter PC, you may have a smaller 14-inch monitor.21-inch monitors are
also available but mostly used by graphics professionals.
VGA and SVGA Monitors
The two most common acronyms you will see on current monitors are VGA or SVGA. Both of these
terms generally refer to how many dots (or pixels) in each direction the monitor can display. VGA is
640x480 (width by height) and SVGA is 800x600. This measurement is called the monitor's
resolution, and more is better! Most new monitors are capable of displaying at least SVGA quality.
In fact, 1,024x768 is somewhat of a minimum to look for.
Almost any VGA or SGVA monitor made in the last few years is capable of displaying any of these
resolutions. However, it's actually the video card that determines what resolution your monitor
displays at any time. The monitor is capable of switching from one resolution to another on
command from the video card.
3 Scanners
Scanners are peripheral devices used to digitize (convert to electronic format) artwork, photographs,
text, or other items from hard copy. In a sense, a scanner works as a pair of eyes for your PC. Your
eyes see an image and translate the image into electrical impulses that travel to and are interpreted by
your brain. Similarly, a scanner captures images and converts them to digital data that travel to and
are interpreted by the computer.
A scanner works by dividing an image into microscopic rows and columns and measuring, like the
film in a camera, how much light (or lack thereof) reflects from each individual intersection of the
rows and columns. Each reflection is recorded as a dot, or picture element (pixel). After the scanner
collects information from each dot, it compiles the result into a digital file on the computer.
There are a wide variety of scanners that work in a number of different ways, but the technology
behind them is essentially the same. The following sections discuss the more popular types of
scanners available today.

Types of scanners
i. Flatbed Scanners
Flatbed scanners look and behave a lot like a photocopier. You lay the item to be scanned on a glass
plate and the scanning head passes below the glass. Flatbed scanners are very versatile: you can scan
objects in a variety of sizes and shapes, including pages from a book, without damaging the original.
While flatbed scanners are
the best choice for a wide variety of uses, if you plan to do a lot of text scanning (called OCR for
Optical Character Recognition) work, keep in mind that flatbeds only accommodate one page at a
time. Scanning multi-page documents can be a slow, tedious process, because you have to manually
remove one page and insert the next.
ii Sheetfed Scanners
Sheetfed scanners look and act more like fax machines. The page or item is fed into the machine,
scanned, then spit out on the other end . A sheetfed scanner is a good choice for large volumes of
text, but not for handling delicate original photographs. Scanning directly from a book or other three-
dimensional object is impossible.
iii Hand Scanners
Hand scanners are a low-cost alternative to their larger, more sophisticated counterparts .As their
name implies, hand scanners are manual devices you move over a flat surface just as you do your
PC's mouse. The hand scanner's advantages are many, but so are its disadvantages. Generally, hand

11
scanners work best for small, uncomplicated images such as company logos or small black-and-white
photographs. You might want a hand scanner if you do not plan to use iton a regular basis, because it
usually does not require adding internal cards to your CPU and it's easily disconnected and stored
away. Most hand scanners can only scan a four inch wide image at one time and require a steady
hand. You're usually provided with software that helps you "sew up" a series of these 4-inch, side-
by-side scans into one image, but this is obviously not as convenient as getting the full image at once.

4 Speakers and Sound


The built-in speakers in most PC cases are used just for making system sounds, such as warning
beeps and action indicators. To play more sophisticated sounds on your PC, you need a set of
external speakers. Usually speakers come in pairs, and there is a plug that connects them to your
sound card. Arrange the speakers with one on the left and one on the right of your desk or work area
to get a stereo effect. Optionally, some speakers come with a subwoofer. This improves the bass (low
notes) sound. If you have a subwoofer with your speakers, it should go on the floor under your desk.
Sound is one of the favorite options on today's PCs. In fact, sound is a standard feature of most new
PCs. Everyone has it’s own uses for sound. You may just want to play a few music CDs with your
CD-ROM drive while you are working, or you may use multimedia applications for presentations or
educational programs. You may just like the sound of your jet engines roaring as you punch the
throttle in a flight simulator.

Components for Sound on Your PC


To produce sound on your PC, you need a sound card and speakers. The sound card is an expansion
card that plugs into one of the slots on your motherboard. This card processes all of the instructions
that have to do with sound, and then sends the sounds to the speakers to be played. The speakers plug
into the sound card and
Sound Cards
Sound cards plug into an expansion slot in your PC. The card has a set of connectors that are exposed
on the back of the PC; you can plug a microphone and speakers into the connectors. Some cards
include an optional connector for a line input, which is used to connect another input source such as
the output from a tape player or portable CD player. Other optional connectors can include a joystick
connector and a MIDI connector (for connecting a MIDI keyboard). The card may include a volume
control, which controls the volume of the speakers and/or headphones.

NOTE: The system unit cannot function without the peripheral devices. The input and the output
units are very important peripheral devices that must be taken care of in setting up a computer
system.

AUXILLARY EQUIPMENT
- Air conditioner
- Voltage stabilizer
- Uninterruptible Power Supply System (UPS)

The auxiliary equipment as their name suggests are not computers but are necessary in a computing
environment in order to ensure proper functioning and smooth running of computing activities. In
this module, we shall address in some details the importance of equipment such as air conditioner,
voltage stabilizer, uninterruptible power system and line transformer in a data processing
environment.
i. Air Conditioner

12
A Computer is an electronic machine. It is, therefore, capable of generating heat. A computer is
manufactured to operate in an environment with a specific temperature range. When the temperature
of the environment in which a computer is kept falls outside the specific range, the computer may
function badly and consequently get
damaged. The free air is basically, dust laden. Dust is metallic in nature and, as such, capable of
conducting electricity. If dust is allowed to settle on a computer, particularly the electronic circuits,
the dust can bridge two circuits. The bridging of two electronic circuits may cause a serious damage
to the computer. Thus, air conditioners are needed ina computer environment to:
a. Condition the temperature
b. Prevent dust.
ii Voltage Stabilizer
A computer when switched on, takes off at a cold state, warms up and gradually gets to a hot state.
At a hot state, a computer is always roaming in an attempt to find something to do. In a situation
where the public electricity such as that of PHCN in Nigeria is cut suddenly, the computer would
suddenly be brought to a halt. The sudden power cut may cause the computer to lose the memory of
some basic house-keeping operations when power eventually returns and the computer is switched
on. The sudden power cut may also cause irreparable damages to the file the computer was
processing at the time the power was suddenly cut.
iii Line Voltage Transformer
We note that computers are built to operate within a specific range of voltages. In the United State of
America, computers are built to operate on 110V. A voltage transformer is a device meant to step up
or step down a voltage as the case may be. In Nigeria, for example, a 110V computer requires a
voltage transformer to step down the 240V to110V. Similarly, in USA, a 2409V current is connected
directly to a 110V computer, the computer power unit will blow up almost immediately.

Today, the technology has improved tremendously such that if a 240V current is connected directly
to a 110V computer, only a fuse, rather than the power unit will blowup. It is worth mentioning, too,
that there is an advanced technology today which permits a computer to operate effectively and
efficiently with the power line voltage ranging between 110V and 240V. The technology supports an
inbuilt switch which can be operated at two terminals namely: the 110V terminus and 240V
terminus. In recent times, the technology has been improved upon such that computers are
manufactured in such a way that they can sense the voltage that is adequate. Thus, if one connects a
110Vcomputer to a 240V current, the 110V computer has an in-built line transformer which
automatically steps down the 240V current to 110V.
iv Uninterruptible Power Supply System (UPS)
An Un-interruptible Power System (UPS) is an auxiliary hardware that is capable of:
(a) Converting the public electricity raw line into fine line, that is, conditioning the voltage that is
fed into the computer.
(b) Storing electrical energy when the public electricity line is life
(c) Releasing the stored electrical energy to the computer when the public electricity line is dead.

Some of the discussed hardware in this section can be clearly view in figure 3.1

13
Figure 3.1: Computer Hardware system

Inside a personal computer:


1. Monitor
2. Motherboard
3. CPU(Microprocessor
4. Main memory (RAM)
5. Expansion cards.
6. Power supply unit.
7. Optical disc drive.
8. Hard disk drive (HDD).
9. Keyboard.
10. Mouse.

14
CHAPTER FOUR
ALGORITHM, FLOWCHART AND PROBLEM SOLVING
4.1 Introduction
Flowchart and algorithm are essential tools for learning programming in computer. Both help
to give detail and clarify all the steps for solving a computational problem. Flowchart is a
diagrammatic representation of how a computational problem will be solved and algorithm is
a step by step procedure of solving the problem. These essential tools for programming will
be discussed in this chapter.

4.2 Algorithm
An algorithm is a set of steps that defines how a task is performed. For example, there are
algorithms for cooking (called recipes), for finding your way through a strange city (more
commonly called Maps or directions). For example:
Task: to make a cup of tea.
Algorithm:
 add water to the kettle,
 boil it, add tea leaves,
 add Milk and sugar, and then serve it in cup.
Before a machine such as a computer can perform a task, an algorithm for performing that
task must be discovered and represented in a form that is compatible with the machine. A
representation of an algorithm is called a program. For the convenience of machines,
programs are encoded in a manner compatible with the technology of the machine. Programs,
and the algorithms they represent, are collectively referred to as software, in contrast to the
machinery itself, which is known as hardware. The study of algorithms began as a subject in
mathematics. Indeed, the search for algorithms was a significant activity of mathematicians
long before the development of today’s computers. The goal was to find a single set of
directions that described how all problems of a particular type could be solved. One of the
best known examples of this early research is the long division algorithm for finding the
quotient of two multiple-digit numbers. Once an algorithm for performing a task has been
found, the performance of that task no longer requires an understanding of the principles on
which the algorithm is based. Instead, the performance of the task is reduced to the process of
merely following directions. The intelligence required to solve the problem at hand is
encoded in the algorithm. Capturing and conveying intelligence by means of algorithms
allows us to build machines that perform useful tasks. Consequently, the level of intelligence
displayed by machines is limited by the intelligence that can be conveyed through algorithms.
We can construct a machine to perform a task only if an algorithm exists for performing that
task. In turn, if no algorithm exists for solving a problem, then the solution of that problem
lies beyond the capabilities of machines. It is the study of algorithms that forms the core of
computer science.
An algorithm can be formerly defined as “an ordered set of unambiguous, executable
steps that defines a terminating process.” The definition requires that:
(i) The set of steps in an algorithm must be ordered. This means that the steps in an
algorithm must have a well-established structure in terms of the order of their
execution. This does not mean, however, that the steps must be executed in a
sequence consisting of a first step, followed by a second, and so on. Some
algorithms, known as parallel algorithms, contain more than one sequence of
steps, each designed to be executed by different processors in a multiprocessor
machine. In such cases the overall algorithm does not possess a single thread of
steps that conforms to the first-step, second-step scenario. Instead, the algorithm’s
structure is that of multiple threads that branch and reconnect as different
processors perform different parts of the overall task. The steps are ordered by
cause and effect.

(ii) Another requirement imposed by the definition is that the steps in an algorithm be
unambiguous. This means that during execution of an algorithm, the information
in the state of the process must be sufficient to determine uniquely and completely
the actions required by each step. In other words, the execution of each step in an
algorithm does not require creative skills. Rather, it requires only the ability to
follow directions.
(iii) The algorithm must consist of executable steps. To appreciate this condition,
consider the instruction: make a list of all the positive integers which would be
impossible to perform because there are infinitely many positive integers. Thus
any set of instructions involving this instruction would not be an algorithm.
Computer scientists use the term effective to capture the concept of being
executable. That is, to say that a step is effective means that it is doable.
(iv) It requires that an algorithm define a terminating process, which means that the
execution of an algorithm must lead to an end. There may problems whose
answers can be obtained algorithmically and problems whose answers lie beyond
the capabilities of algorithmic systems. In this context, a line is drawn between
processes that culminate with an answer and those that merely proceed forever
without producing a result.

4.2.1 Expectation and Examples of an algorithm


For an algorithm to be standard, the following must be maintained;
(a) Correctness:-
 Correct: Algorithms must produce correct result.
 Produce an incorrect answer: Even if it fails to give correct results all the time
still there is a control on how often it gives wrong result.
 Approximation algorithm: Exact solution is not found, but near optimal
solution can be found out. (Applied to optimization problem.)
(b) Less resource usage:
 Algorithms should use fewer resources (time and space).
 Time: considered to be the primary measure of efficiency. It depends
on a variety of backgrounds: like the speed of the Computer, the
language in which the algorithm is implemented, the
compiler/interpreter, skill of the programmers etc.
 Space (Memory): concerned with how much the respective algorithm
Involves the computer memory.
These are typical examples of algorithm:
Example1: An algorithm to convert temperature in Fahrenheit to celsius
Algorithm:
Step1: Start
Step 2: Read Temperature in Fahrenheit F
Step 3: C 5/9*(F32)
Step 4: Print Temperature in Celsius: C
Step5: End
Example2: An algorithm to calculate even numbers between 0 and 99
1. Start
2. I ← 0
3. Write I in standard output
4. I ← I+2
5. If (I <=98) then go to line 3
6. End
Example 3: An algorithm which generates even numbers between 1000 and 2000 and then
prints them in the standard output. It should also print total sum:
1. Start
2. I ← 1000 and S ← 0
3. Write I
4. S ← S + I
5. I ← I + 2
6. If (I <= 2000) then go to line 3
else go to line 7
7. Write S
8. End
Example 4: Design an algorithm with a natural number, n, as its input which calculates the
following formula and writes the result in the standard output:
S = ½ + ¼ + … +1/n
1. Start
2. Read n
3. I ← 2 and S ← 0
4. S= S + 1/I
5. I ← I + 2
6. If (I <= n) then go to line 4
else write S in standard output
7. End
4.2.2 Characteristics of an algorithm:
(a) Must take an input: Any operation you perform need some beginning value/quantities
associated with different activities in the operation. So the value/quantities are given
to the algorithm before it begins.
(b) Must give some output: One always expects output/result (expected value/quantities)
in terms of output from an algorithm. The result may be obtained at different stages of
the algorithm. If some result is from the intermediate stage of the operation then it is
known as intermediate result and result obtained at the end of algorithm is known as
end result. The output is expected value/quantities always have a specified relation to
the inputs.
(c) Definiteness: Each instruction is clear and unambiguous. Each step of an algorithm
must be precisely defined. It is done by well thought actions to be performed at each
step of the algorithm. Also the actions are defined unambiguously for each activity in
the algorithm.
(d) Finiteness: Algorithm terminates after a finite number of steps. It means after every
step one reach closer to solution of the problem and after a finite number of steps
algorithm reaches to an end point.
(e) Effectiveness - every instruction must be basic i.e. simple instruction. Algorithms to
be developed/written using basic operations. Actually operations should be basic, so
that even they can in principle be done exactly and in a finite amount of time by a
person, by using paper and pencil only.

4.3 Flowchart
The flowchart is a diagram which visually presents the flow of data through processing
systems. This means by seeing a flow chart one can know the operations performed and
the sequence of these operations in a system. Algorithms are nothing but sequence of
steps for solving problems. So a flow chart can be used for representing an algorithm. A
flowchart, will describe the operations (and in what sequence) are required to solve a
given problem. You can see a flow chart as a blueprint of a design you have made for
solving a problem.
For example suppose you are going for a picnic with your friends then you plan for the
activities you will do there. If you have a plan of activities then you know clearly when
you will do what activity. Similarly when you have a problem to solve using computer or
in other word you need to write a computer program for a problem then it will be good to
draw a flowchart prior to writing a computer program. Flowchart is drawn according to
defined rules.

4.3.1 Flowchart Symbols


There are 6 basic symbols commonly used in flowcharting of assembly language
Programs: Terminal, Process, input/output, Decision, Connector and Predefined Process.
This is not a complete list of all the possible flowcharting symbols, it is the ones used
most often in the structure of Assembly language programming.

Table 4.1: Flowchat Symbol

Symbol Name Function


Process Indicates any type of internal
operation inside the Processor or
Memory

Input/Output Used for any Input / Output (I/O)


operation. Indicates that the
computer is to obtain data or
output results
Decision Used to ask a question that can be
answered in a binary format
(Yes/No, True/False)
Connector Allows the flowchart to be drawn
without intersecting lines or
without a reverse flow.
Predefined Process Used to invoke a subroutine or an
Interrupt program.
Terminal Indicates the starting or ending of
the program, process, or interrupt
program

Flow Lines Shows direction of flow.

4.3.2 General Rules for Flowcharting


1. All boxes of the flowchart are connected with Arrows. (Not lines)
2. Flowchart symbols have an entry point on the top of the symbol with no other entry
points. The exit point for all flowchart symbols is on the bottom except for the
Decision symbol.
3. The Decision symbol has two exit points; these can be on the sides or the bottom
and one side.
4. Generally a flowchart will flow from top to bottom. However, an upward flow can
be shown as long as it does not exceed three (3) symbols.
5. Connectors are used to connect breaks in the flowchart. Examples are:
• From one page to another page.
• From the bottom of the page to the top of the same page.
• An upward flow of more then three (3) symbols
6. Subroutines and Interrupt programs have their own and independent flowcharts.
7. All flow charts start with a Terminal or Predefined Process (for interrupt programs
or subroutines) symbol.
8. All flowcharts end with a terminal or a contentious loop.
Flowcharting uses symbols that have been in use for a number of years to represent
the type of operations and/or processes being performed. The standardised format
provides a common method for people to visualise

4.3.3 Examples of Flowchart


These examples will help in proper understanding of flowcharting technique.
Example1: Convert temperature Fahrenheit to Celsius:

Example 2: To determine whether a student passed the Exam or not:

START

Input A,B,C,D

Grade= (A+B+C+D)/4

YES If Grade<60
NO

Print “FAIL” Print “PASS”

STOP
Example3: Algorithm for find the greater number between two numbers.

Start

Read A,B

If A > B

Print A Print B

End

Advantages of Flowchart
(i) It is an excellent way of communicating the logic of a program
(ii) It is easy and efficient to analyze problem using flowchart
(iii) During program development cycle, the flowchart plays the role of a blueprint,
which makes program development process easier.
(iv) After successful development of a program, it needs continuous timely
maintenance during the course of its operation. The flowchart makes program or
system maintenance easier.
(v) Conversion from flowchart into any programming language code is very easy.

4.3 Operators
Programming Languages typically support a set of operators that are constructs which behave
generally like functions, but which differ syntactically or semantically from usual functions.
They are Mathematical Operators, Relational Operators and Logical Operators. Examples are
given in table 4.3 (a,b and c) in this section.

Table 4.3a: Mathematical Operators:

Operator Meaning Example


+ Addition A+B
- Subtraction A-B
* Multiplication A*B
/ Division A/B
^ Power A^3 for A3
% Reminder A%B

Table 4.3b: Relational Operators

Operator Meaning Example


< Less than A<B
<= Less than or equal to A <= B
= or == Equal to A=B
# or != Not equal to A # B or A != B
> Greater than A>B
>= Greater than or equal A >= B
to

Table 4.3c: Logical Operators

Operator Example Meaning


AND A < B AND B < C Result is True if both A < B
and B < C are true else false
OR A < B OR B < C Result is True if either A <B
or B < C are true else false
NOT NOT (A > B) Result is True if A > B is
false else true

4.4 Problem Solving


In our life we are bound to solve problems. In our day to day activity such as purchasing
something from a general store and making payments, depositing fee in school, or
withdrawing money from bank account. All these activities involve some kind of problem
solving. It can be said that whatever activity a human being or machine do for achieving a
specified objective comes under problem solving.
An algorithm is a representation of a solution to a problem. If a problem can be defined as a
difference between a desired situation and the current situation in which one is, then a
problem solution is a procedure, or method, for transforming the current situation to the
desired one. We solve many such trivial problems every day without even thinking about it,
for example making breakfast, travelling to the workplace etc. But the solution to such
problems requires little intellectual effort and is relatively unimportant. However, the solution
of a more interesting problem of more importance usually involves stating the problem in an
understandable form and communicating the solution to others. In the case where a computer
is part of the means of solving the problem, a procedure, explicitly stating the steps leading to
the solution, must be transmitted to the computer. This concept of problem solution and
communication makes the study of algorithms important to computer science.

4.4.1 Problem Solving with Computer


You cannot completely understand the basic idea behind development of computer software
without the concept of problem solving. In fact, what you can call computer programming
today is simply the art of imagining a problem and conceiving its stepwise solution and then
finally expressing the solution steps as instructions for a computer system to carry out.
A computer has immense potential for saving time/energy, as most (computational) tasks that
are repetitive or can be generalised can be done by a computer. For a computer to perform a
desired task, a method for carrying out some sequence of events, resulting in accomplishing
the task, must somehow be described to the computer. The figure in 4.1 illustrates the idea of
computer programming as it relates to problem solving:
START

Define Your Problem

Formulate your Solution

Express Your Solution As a


Computer Program

Run the Program on Your


Computer

Check Your Results

Are you Revise Your


OK? No Program
Yes

END

Figure 4.1: Flowchart for Problem Solving Illustration


From figure 4.1, you can see that you have the choice of revising your program until the
computer gives acceptable outputs or results.
There are six major phases that characterize the whole process of developing computer
programs today. If you look back again at the figure 4.1, it simply summarises the idea or job
of programming the solution of a problem. Now, see below the complete phases of computer
programming:

(a) Defining the problem: During this phase, the problem is described and fully analysed
(b) Formulating the solution: This second phase is also called the Design Stage where
you as a programmer, plan the logic of the solution
(c) Writing the program: This phase is also called the starting point of implementation,
which involves writing or coding the program
(d) Debugging and testing the program: The fourth phase consists of debugging or
removing the program errors and the program testing. This is still part of the so-called
stage of implementation
(e) Documenting the program: Documentation of the whole program is very essential in
program development after the successful testing. This involves gathering together
and organizing all the materials involved in its design.
(f) Evaluation the program: Evaluation phase is always an on-going programming
process which assures that the program continues to meet your need for example, as a
user

There are lots of terms used to describe the approaches you might take to solving a problem.
Some are listed below.
Technique Explanation

Divide & Conquer Break the problem down into smaller, solvable sub-problems

Attempting every step towards the solution (one approach that you might
Gradient
take to the U2 problem) even if it seems to move you temporarily away
Descent/Ascent
from the goal

Means-End
Setting sub-goals that lead to the solution
Analysis

Select an answer and see if it works, then select another until you happen
Trial & Error
on the solution

Brainstorming Thinking creatively and sifting through ideas for the best ones

Morphological
Looking at every possible combination of steps in pursuit of a goal
Analysis

Shifting thinking patterns away from the predictable approaches to


Lateral Thinking
solving the problem

Analogy Looking for a similar problem that has already been solved

Hypothesis Testing Assuming an explanation and then testing that assumption


CHAPTER FIVE
DATA REPRESENTATION IN THE COMPUTER AND COMPUTER ARITHMETIC
5.0 Introduction
In this chapter, we will learn how data (text, sound and images) are represented in the computer
and how computations are performed by the computer. Computers often perform a series of
encoding and decoding that is a conversion process from a given format to binary and vice versa.
Since binary is the only language of digital computers, all manipulation of any sort carried out by
computers must be carried out in the binary form. We will now see how the various numbers are
represented by computers and computational arithmetic is performed.
To understand the binary system well, let’s first and foremost consider the most popular
numbering system; the decimal numbers.
5.1 Decimal Numbers System
The number system that we use in our day-to-day life is the decimal number system. Decimal
number system has base 10 as it uses 10 digits from 0 to 9. In decimal number system, the
successive position to the left of the decimal point represents units, tens, hundreds, thousands
and so on. Each position represents a specific power of the base (10). For example, the decimal
number 1234 consists of the digit 4 in the units position, 3 in the tens position, 2 in the hundreds
position, and 1 in the thousands position, and its value can be written as
(1×1000) + (2×100) + (3×10) + (4×l)
(1×103) + (2×102) + (3×101) + (4×l00)
1000 + 200 + 30 + 4
1234

The position of each digit in a decimal number indicates the magnitude of the quantity
represented and can be assigned a weight. The weight for whole number are positive powers of
10 that increase from right to left, beginning with 10 0 = 1
…105 104 103 102 101 100
For fractional numbers, the weights are negative powers of 10 that decrease from left to right
beginning with 10-1
102 101 100.10-1 10-2 10-3…
Decimal point
The value of a weight is determined by its position in the number. The value of a decimal
number is the sum of the digits after each digit has been multiplied by its weight.
Note: This weight is the same as what you know as T H T U (that represents Thousand,
Hundred, Tens and Unit) in Primary schools.
Example 1
Express the decimal number 47 as a sum of the value of each digit.
Solution
The digit 4 has a weight of 10, which is 101, as indicated by its position. The digit 7 has a weight
of 1, which is 100, as indicated by its position.
101 100
4 7 = (4 x 101) + (7 x 100)
= (4 x 10) + (7 x 1) = 40 + 7
Exercise: Determine the value of each digit in 939.
Example 2
Express the decimal number 568.23 as a sum of the value of each digit.
Solution
The weight of 5 is 100 = 102
The weight of 6 is 10 = 101
The weight of 8 is 1 = 100
The fractional digit 2 has a weight of 0.1 = 10 -1 while
The fractional digit 3 has a weight of 0.01 = 10-2
568.23 = (5 x 102) + (6 x 101) + (8 x 100) + (2 x 10-1) + (3 x 10-2)
= (5 x 100) + (6 x 10) + (8 x 1) + (2 x 0.1) + (3 x 0.01)
= 500 + 60 + 8 + 0.2 + 0.03
Exercise: Determine the value of each digit in 67.924

5.2 Binary Numbers


The binary system is another way to represent quantities and it is less complicated than the
decimal system because it has only two digits (0 and 1). The binary system is in base-two
system. The two binary digits 0 and 1 are called bits. Like the decimal system, the position of a 1
or 0 in a binary number indicates its weight or value within the number, the weights of a binary
number are based on power of two (2).

Counting in Binary
Having learnt how to count in decimal, counting in binary is easy and a comparable situation
occurs when you count in binary, except that you have only two digits called bits 0 and 1.

Table 1: Decimal and Binary Numbers Equivalence


Decimal Binary Number
Number
0 0 0 0 0
1 0 0 0 1
2 0 0 1 0
3 0 0 1 1
4 0 1 0 0
5 0 1 0 1
6 0 1 1 0
7 0 1 1 1
8 1 0 0 0
9 1 0 0 1
10 1 0 1 0
11 1 0 1 1
12 1 1 0 0
13 1 1 0 1
14 1 1 1 0
15 1 1 1 1

As you can see from table 1, four (4) bits are required to represent or count from 0 to 15. Note
that we started our decimal numbers from 0, so 0 through 15 make 16 numbers.
In general, with n bits you can count up to a number equal to 2 n – 1, so the largest decimal
number = 2n – 1 while the total number you can count is 2n, the largest decimal number that can
be counted is 2n – 1.
For instance, with 5 bits (n = 5) you can count 25 = 32. While the largest number you can count
is 25 – 1 = 32 – 1 = 31. Because counting start from 0.
Like decimal, the binary number is a weight number, the right-most bits are the LSB (Least
Significant Bit) in a binary whole number and has a weight of 20 = 1. The weight increases from
right to left by a power of two (2) for each bit. The left-most bit is the MSB (Most Significant
Bit); its weight depends on the size of the binary number.
Fractional number can also be represented in binary by placing bits to the right of the binary
point (not decimal point again since we are now dealing with binary, it is called binary point) just
as fractional digits are placed to the right of the decimal point. The left-most bit after the binary
point is the MSB in a binary fractional number and has a weight of 2 -1 = 0.5. The fractional
weight decreases from left to right by a negative power of two for each bit.
The weight structure of binary number is
2n-1 … 23 22 21 20. 2-1 2-2 2-3 … 2-n
Binary point
Where n is the number of bits from the binary point.

Binary to Decimal Conversion


Example 3: Convert the binary whole number 1101101 to decimal
Solution: Determine the weight of each bit, and then find the sum of the weights to get the
decimal number.
Weight: 26 25 24 23 22 21 20
Binary number: 1 1 0 1 1 0 1
1101101 = (1 x 26) + (1 x 25) + (0 x 24) + (1 x 23) + (1 x 22) + (0 x 21) + (1 x 20)
= 64 + 32 + 0 + 8 + 4 + 0 + 1
= 109
Exercise: Convert the binary number 10010001 to decimal

Example 4: Convert the fractional binary number 0.1011 to decimal


Solution: Determine the weight of each bit, and then sum the weight to get the decimal fraction.
Weight: 20 2-1 2-2 2-3 2-4
Binary number: 0. 1 0 1 1
0.1011 = (0 x 20). (1 x 2-1) + (0 x 2-2) + (1 x 2-3) + (1 x 2-4)
= (0 x 1) + (1 x 0.5) + (0 x 0.25) + (1 x 0.125) + (1 x 0.0625)
= 0. (0.5) + (0) + (0.125) + (0.0625)
= 0.6875
Exercise: Convert the binary number 10.111 to decimal

Decimal to Binary Conversion


There are two methods for converting decimal to binary. One way is to determine the positions
of weight whose sum is equal to the decimal number. An easy way to remember binary weights
is that the lowest is 1, which is 20, and that by doubling any weight, you get the next higher
weight; thus a list of seven binary weights would by 64, 32, 16, 8, 4, 2, 1 as you learned in the
last section.
Example 5: The decimal number 9 can be expressed as the sum of binary weights as follows:
9 = 8 + 1 or 9 = 23 + 20
Placing 1s in the appropriate weight position, 23, 20 and 0s in the remaining weight positions (22
and 21) determines the binary number for decimal 9.
23 22 21 20
1 0 0 1 Binary number for decimal 9
Note: That the remaining bit positions or weight positions are zero (0) including 24, 25, 26, …, 2n
Example 6: Convert the following decimal number to binary (a) 12 (b) 25 (c) 58 (d) 82
Solution:
(a) 12 = 8 + 4 = 23 + 22 = 1100
(b) 25 = 16 + 8 + 1 = 24 + 23 + 20 = 11001
(c) 58 = 32 + 16 + 8 + 2 = 25 + 24 + 23 + 21 = 111010
(d) 82 = 64 + 16 + 2 = 26 + 24 + 21 = 1010010
Exercise: Convert the decimal number 125 to binary using the sum of weight method.

The second method for converting decimal to binary is the repeated division-by-2 method. This
method is familiar to you from primary school, to get the binary number for a given decimal
numbers, divide the decimal number by 2 until the quotient is 0. The remainders form the binary
number.
Example 7: Convert the following decimal number to binary, (a) 19 (b) 45
Solution:
(a)
2 19 R
2 9 1 LSB
2 4 1
2 2 0 R = Remainder
2 1 0
0 1 MSB
Read the bits from down to up to get required number 1910 = 100112
(b)
2 45 R
2 22 1 LSB
2 11 0
2 5 1 R = Remainder
2 2 1
2 1 0
0 1 MSB
4510 = 1011012
Exercise: Convert decimal number 39 to binary using successive division by 2

Converting Decimal Fraction to Binary


Let’s now look at fractional conversion.

The sum-of-weight method


The sum-of-weight method can be applied to fractional decimal numbers, as shown in the
example below;
For Example, convert the decimal number 0.625 to binary
0.625 = 0.5 + 0.125 = 2-1 + 2-3 = 0.101
There is a 1 in the 2-1 position, a 0 in the 2 -2 position, and a 1 in the 2-3 position.

Repeated Multiplication by 2
Decimal fraction can be converted to binary by repeated multiplication by 2. For example, to
convert the decimal fraction 0.3125 to binary, begin by multiply 0.3125 by 2 then multiplying
each resulting fractional part of the product by 2 until the fractional product is zero or until the
desired number of decimal places is reached. The carry digits or carries, generated by the
multiplications produce the binary number. The first carry produced the MSB, and the last carry
is the LSB.
For example, convert 0.312510to binary
0.3125 x 2 = 0.625 0 …MSB
0.625 x 2 = 0.25 1
0.25 x 2 = 0.50 0
0.50 x 2 = 1.00 1 …LSB
Now the fractional parts are all zero so we stop. 0.312510 = 0.01012
Exercise: Convert each of the following decimal numbers to binary using the sum-of-weight
method:
(a) 23 (b) 57 (c) 45.5
Exercise: Convert each decimal number to binary by using the repeated division-by-2 method
(repeated multiplication-by-2 for fraction).
(a) 14 (b) 21 (c) 0.375

Binary Arithmetic
Binary arithmetic is essential in all digital computers and in many other types of digital system.
To understand digital systems, you must know the basic binary addition, subtraction,
multiplication and division.

Binary Addition
The four (4) basic rules for adding binary digits (bits) are as follows
0 + 0 = 0 sum of 0 with a carry of 0
0 + 1 = 1 sum of 1 with a carry of 0
1 + 0 = 1 sum of 1 with a carry of 0
1 + 1 = 10 sum of 0 with a carry of 1
Example 8: Add the following binary number
(a) 11 + 11 (b) 100 + 10 (c) 111 + 11 (d) 110 + 100
Solution:
(a) 1 1 3 (b) (c) 1 1 1 7
1 0 0 4
+ 1 1 ≈ +3
+ 1 0 ≈ +2 + 1 1 ≈ +3
1 10 6
1 1 0 6 101 0 10
(d) 1 1 0 6

+ 1 0 0 ≈ +4

1 0 1 0 10
Exercise: Add 1111 and 1100

Binary Subtraction
The four (4) basic rules for subtraction bits are as follows:
0–0=0
1–1=0
1–0=1
0–1=1
0 – 1 with borrow of 1 which you call 2. Remember in binary 10 – 1 = 1, not 2
When subtracting numbers, you sometimes have to borrow from the next column to the left. A
borrow is required in binary only when you try to subtract a 1 from a 0. In this case, when a 1 is
borrowed from the next column to the left, a 1 0 is created in the column being subtracted, and
the last of the four basic rules just listed must be applied.

Example 9: Perform the following binary subtractions:


(a) 11 – 01 (b) 11 – 10
Solution:
(a) 1 1 3 (b) 1 1 3

- 0 1≈ - 1 -1 0≈ - 2

1 0 2 0 1 1

Note: No borrows were required in these examples.


The binary number 01 is the same as 1
Exercise: Subtract 100 from 101

Example 3: Subtract 011 from 101


Solution
1 0 1 5
- 0 1 1 ≈ -3

0 1 0 2
Exercise: Subtract 101 from 110

Binary Multiplication
The four (4) basic rules for multiplication bits are as follows:
0x0=0
0x1=0
1x0=0
1x1=1
This is the same as in decimal.
Example 10: Perform the following binary multiplications
(a) 1 1 x 1 1 (b) 1 0 1 x 1 1 1

Solutions
(a) 1 1 3 (b) 1 1 1 7
x 1 1 3 ≈x x 1 0 1 5 ≈x
1 1 9 1 1 1 35
+1 1 0000 Partial products
1001 +1 1 1

100011
Exercise: Multiply 1101 x 1010

Binary Division
Binary division follows the same procedure as division in decimal

Example 11: Perform the following binary divisions:


(a) 1 1 0 ÷ 1 1 (b) 1 1 0 ÷ 1 1 0
Solution
(a) 110 √11 ≈ 6 √3 (b) 110 √110 ≈ 6 √6
110 ≈ 6 110 ≈ 6

11 3 110 6

10 2 10 0

10

00
Exercise: Divide 1100 by 100

1s and 2s Complement of Binary Numbers


The 1s and 2s complement of a binary numbers are important because they permit the
representation of negative numbers. The method of 2s complement arithmetic is commonly used
in a computer to handle negative numbers.

Finding the 1’s Complement


The 1’s complement of a binary number is found by changing all 1’s to 0’s and all 0’s to 1’s as
shown below;
1 0 1 1 0 0 1 0 Binary number

0 1 0 0 1 1 0 1 1’s complement
The simplest way to obtain the 1’s complement of a binary number with a digital circuit is to
use parallel inverter (NOT circuits), as shown below for an 8-bit binary numbers.
1 0 1 0 1 0 1 0

NOT Gate
0 1 0 1 0 1 0 1

Finding the 2’s Complement


The 2’s complement of a binary number is found by adding 1 to the LSB of the 1’s complement.
2’s complement = (1’s complement) + 1

Example 12: Find the 2’s complement of 1 0 1 1 0 0 1 0


Solution
1 0 1 1 0 0 1 0 Binary number
0 1 0 0 1 1 0 1 1’s complement
+ 1 Add 1
0 1 0 0 1 1 1 0 2’s complement
Exercise: Determine the 2’s complement of 1 1 0 0 1 0

An alternative method of finding the 2’s complement of a binary number is as follows:


Step 1: Starting from the right with the LSB and write the bits as they are up to and including the
first 1. That is, write them as there are until you come across the first 1 write that 1 too
then,
Step 2: Take the 1’s complement of the remaining bits toward the MSB

Example 13: Find the 2’s complement of 1 0 1 1 1 0 0 0 using the alternative method
Solution
1 0 1 1 1 0 0 0 Binary number
0 1 0 0 1 0 0 0 2’s complement

Note: That the circled parts remain the same while the remaining part is the 1’s complement.

Exercise: Find the 2’s complement of 1 1 0 0 0 0 0 0

The 2’s complement of a negative binary number can be realized using inverter (NOT gates) and
an adder as shown below.

1 0 1 0 1 0 1 0 ≈17010

1’s complement 0 1 0 1 0 1 0 1 1
Input bits adder
Carry in (Add 1)

2’s complement 0 1 0 1 0 1 1 0 ≈-17010

To convert from 1’s or 2’s complement back to the original, true (un-complemented) binary
form, use the same procedures described previously. To go from the 1’s complement back to true
binary, reverse all the binary bits. To go from the 2’s complement from back to true binary, take
the 1’s complement of the 2’s complement number and add 1 to the LSB.
This is because the complement of a complement gives back the original un-complemented
number as you know in mathematics.
Given x, the complement of x is –x and complementing –x again gives –(-x) which equals x. So
also in logic, given x the complement is x- and complementing x- = x.

5.3 Signed Numbers


Digital systems such as the computer must be able to handle both positive and negative numbers.
A signed number consists of both sign and magnitude information. The sign indicates whether a
number is a positive or negative, and the magnitude is the values of the number. There are three
forms in which signed integer (whole) number can be represented in binary; sign magnitude, 1’s
complement and 2’s complement. The 2’s complement is the most important and the sign-
magnitude is the least used. Non-integer and very large or small numbers can be expressed in
floating point format.
The Sign Bit
The left most bit in a signed binary number is the sign bit which tell you whether the number is
positive or negative. A 0 sign bit indicate a positive number, and a 1 sign bit indicate a negative
number.

Sign Magnitude Form


When a signed binary number is represented in sign-magnitude, the left-most bit (MSB) is the
signed bit and the remaining bits are the magnitude bits. The binary bits are in true (un-
complemented) binary for both positive and negative numbers. For example, the decimal number
+25 is expressed as an 8-bit signed binary number using the sign-magnitude form as

0 0 0 1 1 0 0 1
Sign bit
Magnitude bits
The decimal number -25 is expressed as 1 0 0 1 1 0 0 1
Note that the only difference between +25 and -25 is the MSB which is the sign bit because the
magnitude bits are in true binary for both positive and negative numbers.
In the sign-magnitude form, the negative number has the same magnitude bit as the
corresponding positive number but the sign bit is a 1 rather than a 0.

1’s Complement Form


Positive number in 1’s complements form is represented the same way as the positive sign-
magnitude numbers. Negative numbers, however are the 1’s complements of the corresponding
positive numbers. For example, using 8-bit the decimal number -25 is expressed as the 1’s
complement of +25 (00011001) as 11100110.
In the 1’s complement form, a negative number is the 1’s complement of the corresponding
positive number.

2’s Complement Form


Positive number is 2’s complement form is represented the same way as in the sign-magnitude
and 1’s complement forms. Negative numbers are the 2’s complements of the corresponding
positive numbers, again using 8-bits let’s take decimal number -25 and express it as the 2’s
complement of -25 (00011001) as 11100111
In the 2’s complement form, a negative number is the 2’s complement of the corresponding
positive number.

Example 14: Express the decimal number -39 as an 8-bit number in the sign-magnitude, 1’s
complement and 2’s complement form.
Solution: First write down the 8-bit number for +39.
00100111
In the sign-magnitude form, -39 is produce by changing the sign bit to 1 and leaving the
magnitude bits as they are which produce 10100111.
In the 1’s complement form -39 is produced by taking the 1’s complement of +39 (00100111),
this produce 11011000.
In the 2’s complement form, -39 is produced by taking the 2’s complement of +39 (00100111) as
follows:
1 1 0 1 1 0 0 0 1’s complement
+ 1
1 1 0 1 1 0 0 1 2’s complement

Exercise: Express +19 and -19 in sign-magnitude, 1’s complement and 2’s complement.

The Decimal Value of Signed Numbers


Sign-Magnitude
Decimal values of positive and negative numbers in the sign-magnitude form are determined by
summing the weights in all magnitude bits.

Example 15: Determine the decimal value of this signed binary numbers expressed in sign-
magnitude: 10010101
Solution
26 25 24 23 22 21 20
0 0 1 0 1 0 1
Summing the weights, we have
(0 x 26) + (0 x 25) + (1 x 24) + (0 x 23) + (1 x 22) + (0 x 21) + (1 x 20)
= 0 + 0 + 16 + 0 + 4 + 0 + 1 = 21
The sign bit is 1 therefore, the decimal number is -21

Exercise: Determine the decimal value of the sign-magnitude number 0 1 1 1 0 1 1 1

1’s Complement
Decimal values of positive numbers in the 1’s complement form are determined by summing the
weight in all bit positions. Decimal values of negative numbers are determined by assigning a
negative value to the weight of the sign bit, sum all the weights and add 1 to the result.

Example 16: Determine the decimal values of the signed-binary number expressed in 1’s
complement: (a) 00010111 (b) 11101000
Solution
(a) The bits and their weights for the positive number are as follows:
-27 26 25 24 23 22 21 20
0 0 0 1 0 1 1 1
= 0 + 0 + 0 + 16 + 0 + 4 + 2 + 1 = +23
(b) -27 26 25 24 23 22 21 20
1 1 1 0 1 0 0 0
= -128 + 64 + 32 + 0 + 8 + 0 + 0 + 0 = -24
Adding 1 to the result we have
-24 + 1 = -23
Notice the negative (-) on the MSB of the left-most bit.

Exercise: Determine the decimal value of the 1’s complement number 11101011

2’s Complement
Decimal values of positive and negative numbers in the 2’s complement form are determined by
summing the weights in all bit position. The weight of the sign bit in a negative number is given
a negative value.

Example 17: Determine the decimal value of the sign-binary number expressed in 2’s
complement.
(a) 01010110 (b) 10101010
Solution
(a) -27 26 25 24 23 22 21 20
0 1 0 1 0 1 1 0
= 0 + 64 + 0 + 16 + 0 + 4 + 2 + 0 = +86
(b) -27 26 25 24 23 22 21 20
1 0 1 0 1 0 1 0
=-128 + 0 + 32 + 0 + 8 + 0 + 2 + 0 = -86
Note that there is no addition of 1 to the result here as in 1’s complement

Exercise: Determine the decimal value of the 2’s complement number 11010111

Range of Signed Integer Number that can be Represented


The range of magnitude of a binary number depends on the number of bits (n). The total
combination = 2n. For 2’s complement signed numbers, the range of values for n-bits number is
Range = -(2n-1) to +(2n-1-1)
Where in each case, there is one sign bit and n-1 magnitude bits. For instance, with four (4) bits
you can represent numbers in 2’s complement ranging from
-(2n-1) ≈ -24-1 = -23 – 8 to + (2n-1) ≈ + (24-1-1) = +(23-1) = 8 – 1 = +7
Similarly, with eight (8) bits you can go from -128 to +127, with sixteen (16) bits you can go
from -32,768 to 32,767 and so on.

5.4 Floating-Point Numbers


To represent very large integer (whole) numbers, many bits are required. There is also a problem
when numbers with both integer and fractional parts, such as 23.5618 need to be represented.
The floating-point number system, based on scientific notation is capable of representing very
large and very small numbers without an increase in the number of bits and also for representing
numbers that have both integer and fractional components.
A floating-point number (also known as a real number) consist of two parts plus a sign. The
mantissa is the part of a floating-point number that represents the magnitude of the number. The
exponent is the part of a floating-point number that represents the number of places that the
decimal point (or binary point) is to be moved.
For example, a decimal number which in integer form is 241,506,800. The mantissa is .2415068
and the exponent is 9. When the integer is expressed as a floating-point number, it is normalized
by moving the decimal point to the left of all the digits so that the mantissa is a fractional number
and the exponent is the power of ten. The floating-point number is then written as: 0.2415068 x
109
For binary floating-point numbers, the format is defined by ANSI/IEEE standard 754-1985 in
three forms: Single-precision, double-precision and extended-precision. These all have the same
basic formats except for the number of bits. Single-precision floating-point numbers have 32-
bits, double-precision floating-point numbers have 64-bits and extended-precision floating-point
numbers have 80-bits, we will restrict ourselves to the single-precision floating-point number
format.

Single-Precision Floating-Point Binary Numbers


In the standard format for a single-precision binary number, the sign bit(s) is the left-most bit
(i.e. MSB), the exponent (E) includes the next eight (8) bits and the mantissa of fractional part
(F) include the remaining 23 bits as shown below:
32 bit
S Exponent (E) Mantissa (F)
In the mantissa or fractional part (f), the binary point is understood to be the left of the 23 bits.
Effectively there are 24 bits in the mantissa because in any binary number the left-most bit
(MSB) is always a 1. Therefore, this 1 is understood to be there although it does not occupy any
actual bit position.
The eight (8) bits in the exponent represent a biased exponent, which is obtained by adding 127
to the actual exponent. The purpose of the bias is to allow very large or very small numbers
without requiring a separate sign bit for the exponents. The biased exponent allows a range of
actual exponent values from -126 to +128.
To illustrate how a binary number is expressed in floating-point format, let’s use 1011010010001
as an example. First, it can be expressed as 1 plus a fractional binary number by moving the
binary point 12 places to the left and then multiplying by the appropriate power of two (2).
1011010010001 = 1.011010010001 x 212
Assuming that this is a positive number, the sign bit (S) is 0. The exponent, 12 is expressed as a
biased exponent by adding it to 127 (12 + 127 = 139).
The biased exponent (E) is expressed as the binary number 10001011. The mantissa is the
fractional part (F) of the binary number, .011010010001. Because there is always a 1 to the left
of the binary point in the power-of-two expression, it is not included in the mantissa. The
complete floating-point number is
S E F
0 10001011 01101001000100000000000
Next, let’s see how to evaluate a binary number that is already a floating-point format. The
general approach to determine the value of a floating-point is expressed by the following
formula;
Number = (-1)s (1 + F) (2E-127)
To illustrate, let’s consider the following floating-point binary number.
S E F
1 10010001 10001110001000000000000

The sign bit is 1. The biased exponent is 10010001 = 145


Applying the formula, we get
Number = (-1)1 (1 . 10001110001) (2145-127)
= (-1) (1.10001110001) (218) = - 1100011100010000000
This floating-point binary number is equivalent to -407688 in decimal. Since the exponent can be
any number between -126 and +128, extremely large and small numbers can be a binary integer
number having 129 bits. Because the exponent determines the position of the binary point,
numbers containing both integer and fractional parts can be represented.
There are two exceptions to the format for floating-point numbers: The number 0.0 is
represented by all 0s and infirmity is represented by all 1s in the exponent and all 0s in the
mantissa.

Example 18: Convert the decimal number 3.248 x 104to a single-precision floating-point binary
number.
Solution: Convert the decimal number to binary
3.248 x 104 = 32580 = 1111110111000002 = 1.11111011100000 x 214
The MSB will not occupy a bit position because it is always a 1. Therefore, the mantissa is the
fractional 23-bit binary number 11111011100000000000000 and the biased exponent is 14 + 127
= 141 = 100011012
The complete floating-point number is
0 10001101 11111011100000000000000

Exercise: Determine the binary value of the following floating-point binary number:
01001100010000100010100110000000

Arithmetic Operation with Signed Numbers


In the last section you learned how signed numbers are represented in three different forms. In
this section, you will learn how signed numbers are added, subtracted, multiplied and divided.
Because the 2’s complement form for representing signed numbers is the most widely used in
computers and microprocessor-based system, the coverage in this section is limited to 2’s
complement arithmetic, bit can be extending to the other forms if necessary.

Addition
Two numbers in the addition are the addend and the subtrahends. The result is the sum, there are
four cases that can occur when two signed binary numbers are added.
1. Both numbers positive
2. Positive number with magnitude larger than negative number
3. Negative number with magnitude larger than positive number
4. Both numbers negative
Let’s take one case at a time using 8-bit signed number as example, the equivalent decimal
numbers are shown for reference.

Both Numbers Positive


Addition of two positive numbers yield a positive number.

Example 19:
0000111 7

0 0 0 0 1 0 0≈ + 4

0001011 11
The sum is positive and is therefore in true (un-complemented) binary.
Positive number with magnitude larger than negative number: Addition of a positive number and
a smaller negative number yield a positive number.

Example 20:
00001111 15
+ 1 1 1 1 1 0 1 0 ≈ + -6
Discard carry 1 00001001 9
The final carry bit that makes the total number of bits to become 9 instead of 8 bits 1’s discarded.
The sum is positive and therefore in true (un-complemented) binary.
Negative Number with Magnitude Larger than Positive Number
Addition of a positive number and larger negative number or two negative numbers yield a
negative number in 2’s complement.

Example 21:
00010000 16

+ 1 1 1 0 1 0 0 0 ≈ + -24
11111000 -8
The sum is negative and therefore is 2’s complement form

Both Numbers Negative


Example 22:

11111011 -5
+ 1 1 1 1 0 1 1 1 ≈ + -9
Discard carry 1 11110010 -14

The final carry is discarded. The sum is negative and therefore in 2’s complement form.
In a computer, the negative numbers are stored in 2’s complement form so, as you can see the
addition process is simple; add the two numbers and discard any final carry bit.

Overflow Condition
When two numbers are added and the number of bits required to represents the sum exceeds the
number of bits in the two numbers, an overflow results as indicated by an incorrect sign bit. An
overflow can occur only when both numbers are positive or both are negative. The following 8-
bit example will illustrate this condition.

Example 23:
01111101 125

0 0 1 1 1 0 1 0 ≈ + 58

10110111 183

Incorrect sign
Magnitude incorrect
In the above example, the sum of 183 requires 8 magnitude bits. Since there are seven magnitude
bits in the number (one bit is sign), there is a carry into the sign bit which produces the overflow
indication.

Numbers are Added Two at a Time


Now let’s look at the addition of a string of numbers, added two at a time. This can be
accomplished by adding the first two numbers, then adding the third number to this result and so
on; this is how computers ass strings of numbers. The addition of numbers taken two at a time is
illustrated.
Example 24: Add the signed numbers.
0 1 0 0 0 1 0 0, 0 0 0 1 1 0 1 1, 0 0 0 0 1 1 1 0 and 0 0 0 1 0 0 1 0.
Solution: The equivalent decimal additions are given for reference.
68 01000100
+ 27 + 00011011 Add 1st two numbers
95 01011111 1st sum
14 + 00001110 Add 3rd number
109 01101101 2nd sum
+ 18 +00010010 Add 4th number
127 01111111 Final sum

Exercise: Add the following signed numbers:


0 0 1 1 0 0 1, 1 0 1 1 1 1 1 1 and 0 1 1 0 0 0 1 1

Subtraction
Subtraction is a special case of addition, for example subtracting +6 (the subtrahend) from +9
(the minuend) is equivalent to adding -6 to +9. Basically, the subtraction operation changes the
sign of the subtrahend and adds it to the minuend. The result of a subtraction is called the
difference.
Note: The sign of a positive or negative binary number is changed by taking its 2’s complement
For example, when you take the 2’s complement of the positive number
0 0 0 0 0 1 0 0 (+4) as the following sum-of-weight evaluation shows:
-128 + 64 + 32 + 16 + 8 + 4 = -14
Hence, to subtract two signed numbers, take the 2’s complement of the subtrahend and add.
Discard and final carry bit.

Example 25: Perform each of the following subtractions of the signed numbers
a. 0 0 0 0 1 0 0 0 – 0 0 0 0 0 0 1 1
b. 0 0 0 0 1 1 0 0 – 1 1 1 1 0 1 1 1
c. 1 1 1 0 0 1 1 1 – 0 0 0 1 0 0 1 1
d. 1 0 0 0 1 0 0 0 – 1 1 1 0 0 0 1 0
Solution: The equivalent decimal subtractions are given for reference.
a. In this case, 8 – 3 = 8 + (-3) = 5

00001000 Minuend (+8)

+ 11111101 2’s complement of subtrahend (-3)


Discard carry
1 00000101 Difference (+5)
b.
c. In this case, 12 – (-9) = 12 + 9 = 21
00001100 Minuend (+12)
+ 00001001 2’s complement of subtrahend (+9)

00010101 Difference (+21)


d.
e. In this case, -25 – (+19) = -25 + (-19) = -44
11100111 Minuend (-25)

+ 11101101 2’s complement of subtrahend (-19)


Discard carry
1 11010100 Difference (-44)
f. In this case, -120 – (-30) = -120 + 30 = -90
10001000 Minuend (-120)
+ 00011110 2’s complement of subtrahend (+30)

10100110 Difference (-90)


Exercise: Subtract 0 1 0 0 0 1 1 1 from 0 1 0 1 1 0 0 0
Multiplication
The numbers in a multiplication are the multiplicand, the multiplier and the product. These are
illustrated in the following decimal multiplication.
8 Multiplicand
x 3 Multiplier

24 Product
The multiplication operation in most computers is accomplished using addition. Now let’s see
how multiplication is done.
Direct addition and partial products are two basic methods for performing multiplication. Using
addition in the direct addition method; you add the multiplicand a number of times equal to the
multiplier. In the previous decimal example (3 x 8), three multiplicands are added 8 + 8 + 8 = 24.
The disadvantage of this approach is that it becomes very lengthy if the multiplier is a large
number. For example, 75 x 350, you must add 350 to itself 75 times. Incidentally, this is why the
term is used to mean multiply. When two binary numbers are multiplied, both numbers must be
in true (un-complemented) form. The direct addition method is illustrated below in example 26,
adding two binary numbers at a time.

Example 26: Multiply the signed binary numbers 0 1 0 0 1 1 0 1 (Multiplicand) and 0 0 0 0 0 1 0


0 (multiplier) using the direct addition method.
Solution: Since both numbers are positive, they are in true form and the product will be positive.
The decimal value of the multiplier is 4, so the multiplicand is added to itself our times as
follows; 01001101 1st time
+ 01001101 2nd time

10011010 Partial sum


+ 01001101 3rd time

11100111 Partial sum

+ 01001101 4th time


Discard carry
1 00110100 Product
Since the sign bit of the multiplicand is 0, it has no effect on the outcome. All of the bits in the
product are magnitude bits.

Exercise: Multiply 0 1 1 0 0 0 0 1 by 0 0 0 0 0 1 1 0 using the direct addition method.

The partial products method is perhaps the more common one because it reflects the way you
multiply long hand. The multiplicand is multiplied by each multiplier digit beginning with the
least significant digit. The result of the multiplication of the multiplicand by a multiplier digit is
called a partial product.
Each successive partial product is moved (shifted) one place to the left and when all the partial
products have been produced, they are added to get the final product.
Here is a decimal example
239 Multiplicand
x 123 Multiplier

717 1st partial product (3 x 239)


478 2nd partial product (2 x 239)
+ 239 3rd partial product (1 x 239)
29397 Final product

The sign of the product depends on the sign of the multiplicand and the multiplier according to
the following rules.
1. If the signs are the same, the product is positive
2. If the signs are different, the product is negative

Example 27: 0 1 0 1 0 0 1 1 x 1 1 0 0 0 1 0 1
Solution:
Step 1: The sign bit of the multiplicand is 0 and the sign bit of the multiplier is 1, the sign bit of
the product will be 1 (negative)
Step 2: Take the 2’s complement of the multiplier to put it in a true form
11000101 0 0 1 1 1 0 1 1 2’s complement
Step 3 and 4: The multiplication proceeds as follows
Note that only the magnitude bits are used in these steps. The sign bits of the numbers are left out
since we know that the final product is negative (sign bit 1).
1010011
x 0111011

1010011 1st partial product


+1 0 1 0 0 1 1 2nd partial product
11111001 Sum of 1st and 2nd
+ 0000000 3rd partial product
011111001 Sum
+ 1010011 4th partial product
1110010001 Sum
+ 1010011 5th partial product
100011000001 Sum
th
Step 5: Since the sign of product is a 1 as determined in step 1, take the 2’s complement of the
product.
11001100100001 0110011011111
Attach the sign bit (1) to get
1 0110011011111

Exercise: Verify that the multiplication above is correct by converting the result in question 27
above to decimal number and performing the multiplication.

Division
The numbers in a division are the dividends, the divisor and the quotient. These are illustrated in
the following standard division format:
Dividend
= Quotient
Divisor
The division operation in computers is achieved using subtraction. Since subtraction is done with
an adder, division can also be done with an adder.
The result of a division is called the quotient; this is the number of times that the divisor will go
into the dividend. This means that the divisor can be subtracted from the dividend a number of
times equal to the quotient, as illustrated by dividing 21 by 7 below.

21 Dividend

-7 1st subtraction of divisor

14 1st partial remainder

-7 2nd subtraction of divisor

7 2ndpartial remainder

-7 3rd subtraction of divisor

0 Zero remainder

In this example, the divisor was subtracted from the divided three times before a remainder of
zero was obtained. Therefore, the quotient is 3.
The sign of the quotient depends on the sign of the dividend and the divisor according to the
following rules;
1. If the signs are the same, the quotient is positive
2. If the signs are different, the quotient is negative.
When two binary numbers are divided, both numbers must be in true (un-complemented) form

Example 28: Divide 0 1 1 0 0 1 0 0 by 0 0 0 1 1 0 0 1


That is, 0 1 1 0 0 1 0 0 / 0 0 0 1 1 0 0 1
Solution:
Step 1: The sign of both numbers are positive, so the quotient will be positive, the quotient is
initially zero: 0 0 0 0 0 0 0 0
Step 2: Subtract the divisor from the dividend using 2’s complement addition (remember that
final carries are discarded).

01100100 Dividend

+ 11100111 2’s complement partial remainder


Discard carry 1 01001011 1st positive partial remainder

Add 1 to quotient: 0 0 0 0 0 0 0 0 + 0 0 0 0 0 0 0 1 = 0 0 0 0 0 0 0 1
Step 3: Subtract the divisor from the 1st partial remainder using 2’s complement addition.
01001011 1st partial remainder
+ 11100111 2’s complement divisor
00110010 Positive 2nd partial remainder
Step4: Subtract the divisor from 2 nd partial remainder using 2’s complement addition
00110010 2nd partial remainder
+11100111 2’s complement divisor
01001011 Positive 3rd partial remainder
Add 1 to quotient: 0 0 0 0 0 0 1 0 + 0 0 0 0 0 0 0 1 = 0 0 0 0 0 0 1 1.
Step 5: Subtract the divisor from the 3rd partial remainder using 2’s complement addition.
00011001 3rd partial remainder
+1 1 1 0 0 1 1 1 2’s complement divisor
00000000 zero remainder
Add to quotient: 0 0 0 0 0 0 1 1 + 0 0 0 0 0 0 0 1 = 0 0 0 0 0 1 0 0
(Final quotient), the process is complete.

Exercise: Verify that the process is correct by converting the result obtained in question 28
above to decimal numbers and performing the division.

Hexadecimal Numbers
The hexadecimal (HEX) number system has 16 characters; (0 through 15) it is primarily used as
a compact way of displaying or writing binary numbers because it is very easy to convert
between binary and HEX. As you are probably ware, long binary numbers are difficult to read
and write because it is easy to drop or transpose a bit. Since computers and microprocessors
understand only 1’s and 0’s, it is necessary to use these digits when you program in “machine
languages”.
The HEX numbers system has a base of sixteen (16); that is, it is composed of 16 numeric and
alphanumeric characters. Most digital systems like computers process binary data in groups that
are multiples of four bits, making the HEX number system very convenient because each HEX
digit represents a 4-bit binary numbers as shown below:
Table 2: Decimal, Binary and Hexadecimal Numbers Equivalence

Decimal Binary Hex


0 0000 0
1 0001 1
2 0010 2
3 0011 3
4 0100 4
5 0101 5
6 0110 6
7 0111 7
8 1000 8
9 1001 9
10 1010 A
11 1011 B
12 1100 C
13 1101 D
14 1110 E
15 1111 F

We will use the subscript 16 to indicate HEX number to avoid confusion with decimal numbers;
sometimes you may see “h” following a HEX number.

Counting in Hex
How do you count in HEX once you get to F? Simply start over with another column and
continue as follows: 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 1A, 1B, 1C, 1D, 1E, 1F, 20, 21, 22, 23,
24, 25, 26, 27, 28, 29, 2A, 2B, 2C, 2D, 2E, 2F, 30…
With two HEX digits, you can count up to FF16, which is equivalent to decimal 255. To count
beyond this, three HEX digits are needed, for instance, 100 16 is decimal 256, 10116 is decimal
257, and so forth. The maximum 3-digit HEX number is FFF16 or decimal 4,095. The maximum
4-digits HEX number is FFFF16, which is equivalent to decimal 65,535.

Binary-to-Hex Conversion
To convert from binary to HEX is simple. Break the binary number into 4 part groups, starting
from the right-most bit and replace each 4-bits group with the equivalent HEX symbol.

Example 29: Convert the following binary number to HEX


(a) 1 1 0 0 1 0 1 0 0 1 0 1 0 1 1 1 (b) 1 1 1 1 1 1 0 0 0 1 0 1 1 0 1 0 0 1
Solution:
(a) 1 1 0 0 1 0 1 0 0 1 0 1 0 1 1 1

C A 5 7 = CA5716
(b) 0 0 1 1 1 1 1 1 0 0 0 1 0 1 1 0 1 0 0 1

3 F 1 6 9 = 3F16916
Two zeros have been added in part (b) to complete a 4-bits group at the left
Note: we use the vertical lines to divide the numbers into groups of four binary digits (nibbles)

Exercise: Convert the binary number 1 0 0 1 1 1 1 0 1 1 1 1 0 0 1 1 1 0 0 to HEX

Hex to Binary Conversion


To convert from a HEX number to binary number, reverse the process and replace each HEX
symbol with the appropriate four bits.

Example 30: Determine the binary number of the following HEX numbers.
(a) 10A416 (b) CF8E16 (c) 974216
Solution:
(a) 1 0 A 4

1 0000 1010 0100


(b) C F 8 E

1100 1111 1000 1110

(c) 9 7 4 2

1001 0111 0100 0010


In (a), the MSB is understood to have three zeros preceding it, thus forming a 4-bits group.
Exercise: Convert the HEX number 6BD316 to binary

Hex to Decimal Conversion


One way to find the decimal equivalent of a HEX number is to first convert the HEX number to
binary and then convert from binary to decimal.

Example 31: Convert the following HEX numbers to decimal;


(a) 1C16 (b) A8516
Solution: Remember; convert the HEX number to binary first, then to decimal
(a) 1 C

0001 1100 = 24 + 23 + 22 = 16 + 8 + 4 = 2810


(b) A 8 5

1010 1000 0101 = 211 + 29 + 27 + 22 + 20 = 2048 + 512 + 128 + 4 + 1 = 269210


Exercise: Convert the HEX number 6BD to decimal.

Another way to convert a HEX number to its equivalent decimal is to multiply the decimal value
of each HEX digit by its weight and then take the sum of these products. The weights of HEX
number are increasing powers of 16 (from right to left). For a 4-digit HEX number, the weights
are;
163 162 161 160
4096 256 16 1
Example 32: Convert the following HEX numbers to decimal;
(a) E516 (b) B2F816
Solution: Recall from Table 1, that letters A through F represents decimal number 10 through
15, respectively.
(a) E516 = (E x 16) + (5 x 1) = (14 x 16) + (5 x 1) = 224 + 5 = 229 10
(b) B2F816 = (B x 4096) + (2 x 256) + (F x 16) + (8 x 1)
= (11 x 4096) + (2 x 256) + (15 x 16) + (8 x 1)
= 45,056 + 512 + 240 + 8 = 45,81610
Exercise: Convert 60A16 to decimal.

Decimal to HEX Conversion


This is done by repeated division by 16 and taking the remainder.
16 650 R
16 40 10 A
16 2 8
0 2 = 28A

Exercise: Convert decimal 2591 to HEX.

Hex Addition
In HEX addition, remember that A to F represents 10 to 15 in decimal, so look at the digits in
terms of their decimal equivalent.
Example 33: Add the following HEX numbers
(a) 2316 + 1616 (b) 5816 + 2216 (c) 2B16 + 8416 (d) DF16 + AC16
Solution:
(a) (b) (c) (d) DF16
2316 5816 2B16

+ 2216 + 8416 + AC16


+ 1616
7A16 AF16 18B16
3916
Exercise: Add AC16 and 3A16.

Hex Subtraction
Various methods exist in HEX subtraction
Method 1:
HEX Binary 2’s complement in binary 2’s complement in HEX.
Example 34:
2A 00101010 11010110 D6
Method 2:
HEX Subtraction from maximum 1’s complement in HEX +1 2’s complement in
HEX
Method 3:

HEX 0123456789ABCDEF
FEDCBA9876543210
1’s complement in HEX

1’s complement in HEX + 1


For example;
2A
0 1 2 3 4 5 6 7 8 9 A B C D E F
D5 + 1 D6
F E DCBA 9 8 7 6 5 4 3 2 1 0

Example 35: Subtract the following HEX numbers


(a) 8416 – 2A16 (b) C316 – 0B16
Solution:
(a) 2A16 = 0 0 1 0 1 0 1 0
2’s complement of 2A16 = 1 1 0 1 0 1 1 0 = D616
8416
+ D616
Discard carry 1 5A16 Drop carry as in 2’s complement addition
The difference is 5A16
(b) 0B16 = 0 0 0 0 1 0 1 1
2’s complement of 0B16 = 1 1 1 1 0 1 0 1 = F516
C316
+ F516
Discard carry 1 Drop carry
B816
The difference is B816
Exercise: Subtract 17416 from BCD16

Octal Numbers
Like the HEX numbers system, the octal number system provides a convenient way to express
binary numbers and codes. However, it is used less frequently than HEX in conjunction with
computers and microprocessors to express binary quantities for input and output purposes. The
octal number system is composed of eight digits which are 0 through 7.

Octal to Decimal Conversion


The octal number system has a base of eight and the conversion follow the same pattern as in
HEX.
Example 36: Convert 2374 to base ten (decimal)
Weight: 83 82 81 80
2 3 7 4
Solution:
23748 = (2 x 83) + (3 x 82) + (7 x 81) + (4 x 80)
= (2 x 512) + (3 x 64) + (7 x 8) + (4 x 1)
= 1024 + 192 + 56 + 4 = 127610

Decimal to Octal Conversion


Here we use the long division method

Example 37: Convert the decimal number 359 to octal


8 359 R
8 44 7
8 5 4
0 5 = 5478

Octal to Binary Conversion


Because each octal digit can be represented by 3-bit binary number, it is very easy to convert
from octal binary. Each octal digit is represented by three bits as shown below:

Octal digit 0 1 2 3 4 5 6 7
Binary 000 001 010 011 100 101 110 111

To convert an octal number to a binary number, simply replace each octal digit with the
appropriate three bits.
Example 38: Convert each of the following octal numbers to binary
(a) 138 (b) 258 (c) 1408 (d) 75268
Solution:
(a) 1 3

001 011

001011
(b) 2 5

010 101

010101
(c) 1 4 0

001 100 000

001100000
(d) 7 5 2 6

111 101 010 110


111101010110
Binary to Octal Conversion
This is the reverse of octal to binary conversion

Example 39:Convert each of the following binary number to octal


(a) 110101 (b) 101111001 (c) 100110011010 (d) 11010000100

Solution
(a) 1 1 0 1 0 1

6 5 = 658
(b) 1 0 1 1 1 1 0 0 1

5 7 1 = 5718
(c) 1 0 0 1 1 0 0 1 1 0 1 0

4 6 3 2 = 46328
(d) 0 1 1 0 1 0 0 0 0 1 0 0

3 2 0 4 = 32048
Exercise: Convert the binary number 1 0 1 0 1 0 1 0 0 0 1 1 1 1 1 0 0 1 0 to octal.

5.5 Binary Coded Decimal (BCD)


Binary coded decimal (BCD) is a way to express each of the decimal digits with a binary code.
There are only ten codes groups in the BCD system, so it is very easy to convert between
decimal and BCD. Because we like to read and write in decimal, the BCD code provides an
excellent interface to binary systems. Examples of such interfaces are keypad inputs and digital
readouts.

The 8421 Code


The 8421 code is a type of BCD code. BCD means that each decimal digit, 0 through 9 is
represented by a binary code of four (4) bits. The designation 8421 indicates the binary weights
of four (4) bits (23 22 21 20). The ease of conversion between 8421 code numbers and the familiar
decimal numbers is the main advantage of this code.

Decimal digit: 0 1 2 3 4 5 6 7 8 9
BCD: 0000 0001 0010 0011 0100 0101 0110 0111 1000 1001

Invalid Codes
You should realize that with four bits, sixteen numbers (0000 through 1111) can be represented
but in the 8421 code, only ten of these are used. The six code combinations that are not used;
1010, 1011, 1100, 1101, 1110 and 1111 representing decimal 10 to decimal 15 are invalid in the
8421 BCD code.
To express any decimal number in BCD, simply replace each decimal digit with the appropriate
4-bits code.

Example 40: Convert each of the following decimal numbers to BCD.


(a) 35 (b) 98 (c) 170 (d) 2469
Solution:
(a) 3 5

0011 0101
00110101

(b) 9 8

1001 1000
10011000
(c) 1 7 0

0001 0111 0000


000101110000
(d) 2 4 6 9

0010 0100 0110 1001


0010010001101001

BCD to Decimal Conversion


It is equally easy to determine a decimal number by converting BCD to decimal. Start at the
right-most bit and break the code into group of four bits and then write the decimal digit
represented by each 4-bit group.

Example 41: Convert each of the following BCD codes to decimal


(a) 10000110 (b) 001101010001 (c) 1001010001110000
Solution
(a) 1 0 0 0 0 1 1 0

8 6 = 8610
(b) 0 0 1 1 0 1 0 1 0 0 0 1

3 5 1 = 35110
(c) 1 0 0 1 0 1 0 0 0 1 1 1 0 0 0 0

9 4 7 0 = 947010
Exercise: Convert the BCD codes 10000010001001110110 to decimal.

BCD Addition
BCD is a numerical code and can be used in arithmetic operation. Addition is the most important
operation because the other three operations (subtraction, division, and multiplication) can be
accomplished by the use of addition. Here is how to add two BCD numbers:
Example 42: Add the following BCD numbers
(a) 0011 + 0100 (b) 00100011 + 00010101 (c) 10000110 + 00010011
(d) 010001010000 + 010000010111
Solution: The decimal number additions are shown too.
(a)
0011 3
+ 0100 ≈ + 4
0111 7
(b)
00100011 23
+ 00010101 ≈ + 15
00111000 38
(c) 10000110 86
+ 00010011 ≈ + 13
10011001 99
(d) 010001010000 450
+ 011000010111 ≈ + 417
100001100111 867
Note: That in each case the sum in any 4-bit column does not exceed 9, and the results are valid
BCD numbers.

Exercise: Add the BCD number: 1001000001000011 + 0000100100100101.


Other codes exist for character represented in the computer system such as widely used
American Standard Codes for Information Interchange (ASCII) code.
CHAPTER SIX

INTERNET AND ONLINE RESOURCES

6.1 Computer Network


This is two or more connected computer which can share resource like a printer, an internet
connection, application, etc. It is a collection of computer systems and devices which are
linked together using a wireless network or via communication devices and transmission
media. The network provides connectivity between computers and devices within a restricted
range where only one entity is controlled or authorized to manage the entire system. Three
types of Networks are:
a) Local Area Network (LAN)
LAN is a network that connects a small number of the system in a relatively close
geographical area. E.g., a floor or nearby surrounding of a building. The

Figure 6.1: Design of Local Area Network

b) Metropolitan Area Network (MAN)


It is a communication infrastructure that has been developed in and around large
cities.

Figure 6.2: Design of Metropolitan Area Network


c) Wide Area Network (WAN)
It is a network that connects two or more local-area networks over a large geographic
distance. WAN spans across a large geographic area, such as a state, province or
country

Figure 6.3: Design of Wide Area Network

d) Personal Area Network (PAN)


It is a network arranged within an individual person, typically within a range of 10
meters. It is used for connecting the computer devices for personal use Personal
computer devices that are used to develop the personal area network are the laptop,
mobile phones, media player and play stations.

Figure 6.4: Design of Personal Area Network

6.2 The Internet

The Internet is a global network of computer networks utilizing a suite of protocols called the
TCP/IP (Transmission Control Protocol/Internet Protocol) that supports interconnection of a
number of different computer networks. The Internet covers large, international Wide Area
Networks (WAN’s) as well as smaller Local Area Networks (LAN’s) and individual
computers connected to the Internet worldwide. The Internet supports communication and
sharing of data, and offers a vast amount of information through a variety of services and
tools.
6.2.1 Internet versus Computer Network

Properties Network Internet


Connect the system using Connect networks across the
Connection
different parameters. world.
One entity has administrative No entity controls the
Connectivity
rights to manage the network system.
Hundreds or a few thousand
Millions of computers get
Amount number of PC, get linked at
linked at one time.
one time.
To get the knowledge and
To exchange data and
Objective communicate over the
collaborate with peers.
Internet.
Local Area Network, Wide
Area Network, Campus Area
Type World Wide Web.
Network, and Home Area
Network.

6.3 Major Internet tools and services

The Internet has several tools and services that makes it ideal as an information resource.
Each of these features has its own merits and therefore should be utilized depending on the
type of information one needs to access.

(a) Electronic-Mail

This is the most popular service available on the Internet, e-mail as a form of correspondence
has revolutionalized the way we communicate with each other. It is a way of sending
messages from one computer to another. Its ability to send files through attachments also
factors in its popularity. It is readily available, and in most cases free of charge, this speedy
alternative to postage mail comprises the bulk of traffic on the Internet. Almost all internet
users have at least one e-mail address, and in some cases, several addresses. It has also
become the most basic form of identification on the Internet, with a lot of websites requiring
an e-mail address before offering services.

(b) Newsgroups

Newsgroups are an online forums for discussion of related topics, accessible by a newsreader.
Some newsgroups allow postings or messages from anyone, while others are moderated
(postings are screened). Several university departments have also set up newsgroups for
specific issues and class use. On the Internet, there are literarily thousands of newsgroups
covering every conceivable interest. To view and post messages to a newsgroup, you need a
news reader, a program that runs on your computer and connects you to a news server on the
Internet.

(c) Internet Relay Chat

Using chat is like "talking" to other people who are online at the same time as you are.
Special software allows typed-in messages to be viewed by everyone taking part at that time.
Chats can be ongoing or scheduled for a particular time and duration. Most chats are focused
on a particular topic of interest and some involve guest experts or famous people who "talk"
to anyone joining the chat. Topics of interest are organized into “channels”, facilitating
specialized chat sessions that occur in chatrooms. More advanced forms of chat use sound
cards to allow voices and 2D or 3D characters called “avatars” to represent the participants.
Some websites have built in chatrooms enabling on-site chatting e.g. the U.S. Patriot Tactical
using SMS-to-Chat services that allows clients to start a live chat with their support team via
a simple text message.

(d) Telnet

Telnet is a client software allowing a user to login from a local desktop computer to a remote
server, the Telnet host, and use its resources. Access is usually controlled by passwords given
to each individual or group. Once access is given, the remote user can issue commands or use
the resources of the host, depending on the level of access given the user. It is mainly used by
libraries to allow access to information stored in their computers.

(e) File Transfer Protocol (FTP)

File Transfer Protocol or FTP is an Internet utility that allows the transfer of files from one
location to another. In order to do this, one must have an FTP program to connect to other
servers and be able to download files. These FTP programs are available both commercially
and for free, and offer various features. Most modern web browsers have built in FTP
capabilities enabling downloads through websites.

(f) World Wide Web

The World Wide Web (WWW or W3) was invented by Tim Berners-Lee in 1991 and further
developed at the CERN labs in Switzerland in the early 1990s. It is a vast collection of
interconnected files and programs spanning the globe and retrievable via a client-server
system utilizing HTML (Hyper Text Markup Language) enabled documents called webpages.
It is responsible for the so-called Internet boom, transforming it from a largely academic
domain into a commercial one. It has grown to encompass not only its native http protocol,
but also ftp, newsgroups, e-mails, chat and telnet. As a result of this, most people equate the
Web with the Internet. The Web is accessed by programs called browsers (e.g., Netscape
Navigator or Internet Explorer, Google Chrome, Firefox e.t.c.). These browsers enable
webpages and websites containing multimedia content and applications to be accessed
anytime, anywhere. Users navigate the Internet by following links from one document to
other documents on computers located anywhere on the globe. These links are called
hyperlinks and connect the contents of Webpages to each other as well as to other Webpages
identified by their URLs (Uniform Resource Locators).

(g) Google Search

Google is the gatekeeper to the World Wide Web and the keyholder to all the answers to your
questions. Type keywords and find the best answer possible. There’s a reason why it’s ranked
the number one website in the world, you know.

(h) Google Drive

Google Drive is an easy way to drag-and-store all of your documents onto a Google account.
You can view documents anytime and anywhere with internet access. If you’re running an
online business with multiple employees, use Google Drive to share documents and pass
information.

(i) WordPress

This is a free to use blogging platform. It allow you create your own domain and have a
website running in minutes. WordPress is arguably the goto blogging website used by
millions of businesses online. It’s free and available on Linux, PC, and MAC.

(j) Ecommerce

Ihis is also known as electronic commerce or internet commerce, refers to the buying and
selling of goods or services using the internet, and the transfer of money and data to execute
these transactions. There are six basic types of e-commerce. e.g. Business-to-Business (B2B),
Business-to-Consumer (B2C), Consumer-to-Consumer (C2C), Consumer-to-Business (C2B),
Business-to-Administration (B2A) and Consumer-to-Administration (C2A). All of them
represent a different purchasing dynamic

6.4 History of the Internet.

The Internet started as a military network called ARPANET (Advanced Research Projects
Agency Network), which was involved in networking research. The research involved the
creation of standards and protocols that will support interconnection of a number of computer
networks. It also involved the creation of applications and technologies that utilize current
and emerging technologies. This process continues as the Internet grows dynamically.

The Internet later expanded to include Universities, Businesses and Individuals. However, the
Internet only started to gain popularity with the casual computer user in the 1990s, with the
creation of the World Wide Web, followed by the introduction of Mosaic, the first graphical
Web browser. Today, the Internet is also referred to as the Net, Information Superhighway,
and Cyberspace.

6.5 How the Internet works?

The following are some of the technologies that make the Internet work:
 Protocols – standardized rules that define how computers communicate and exchange
data.
 IP(Internet Protocol)address – unique number used to identify computers on the
Internet
 Domain name – structured naming system to locate computers on the Internet
 URL – uniform naming scheme that specifies unique addresses of Internet resources
 Client and server – computing architecture used by most Internet services

Internet Protocols

Below are some of the Internet Protocols used by Internet tools and services;

(a) TCP/IP (Transmission Control Protocol / Internet Protocol) -The Internet is a packet-
switching network that uses TCP/IP as its core protocol. TCP/IP is a suite of protocols
that govern network addresses and the organization and packaging of the information
to be sent over the Internet. Transmission Control Protocol (TCP) handles the flow
control and recovery of packets, while Internet Protocol (IP) is responsible for
addressing and forwarding of individual packets.
(b) HTTP (Hypertext Transfer Protocol) – a protocol for accessing and transmitting
World Wide Web documents
(c) FTP (File Transfer Protocol) – a protocol for transferring files from one computer to
another
(d) Gopher Protocol – a protocol for accessing documents via Gopher menus (no longer
widely used)
(e) Telnet Protocol – a protocol that allows users to logon to a remote computer
(f) SMTP (Simple Mail Transfer Protocol) – a protocol for sending and managing
electronic mails (e-mail)

IP address

Unlike local computer networks which are centrally controlled, the Internet is decentralized
by design. Its operators can choose which Internet services to use and which services to make
available to the global Internet community. Each Internet computer, called a host, is
independent and has a unique address called the IP address. TCP/IP uses the IP address to
route packets of information from a sender to a location on the Internet. The IP address
consists of four sets of numbers ranging from 0 to 255.

Example of IP address is 249.7.13.53


• The first two number sets designate the network
• The third number set identifies the local network
• The fourth number set identifies the particular machine

Domain Names

Domain names are the alias or English- language equivalent of a computer’s IP address. The
Domain Name System (DNS) allows the use of easier to remember domain names instead of
IP addresses to locate computers on the Internet. Domain Name Resolvers scattered across
the Internet translate domain names into IP addresses

Domain Names have two parts: the first part names the host computer while the second part
identifies the top-level domain. Accordingly, there are two types of Top-Level Domains
(TLD);generic Top-Level Domains and country code Top-Level Domains. The TLD
identifies the type of host; for example a domain that ends with .edu is an educational
institution. Domain names are used in URLs and e-mail addresses.

 Generic Top-Level Domains

Only a few top-level domains are currently recognized, but this is changing. Here is a
list of the domains generally accepted by all:

.edu -- educational site (usually a university or college) e.g. lautech.edu.ng


.com -- commercial business site
.gov -- U.S. governmental/non-military site
.mil -- U.S. military sites and agencies
.net -- networks, internet service providers, organizations
.org -- U.S. non-profit organizations and others

Additional Top-Level Domains are;

.aero -- restricted use by air transportation industry


.biz -- general use by businesses
.coop -- restricted use by cooperatives
.info -- general use by both commercial and non-commercial sites
.museum -- restricted use by museums
.name -- general use by individuals
.pro -- restricted use by certified professionals and professional entities

 Country Code Top-Level Domains

.ng – Nigeria
.ph – Philippines
.cn – China
.sg – Singapore
.fj – Fiji
.uk – United Kingdom
The complete list can be accessed at http://www.iana.org/cctld/cctld-whois.htm

Uniform Resource Locator

A URL or Uniform Resource Locator is the unique address of a given webpage. Knowing the
URL allows you to locate a given webpage. Much like a house address, the URL consists of
several parts: the protocol, the domain name and the path.

• Protocol – lets the computer know how to process the information it receives
• Domain name – Internet address of the computer hosting the site and storing the documents
• Path – lets the computer know which directory and file to access
In the example http://www.amazon.com/books/children.html
• "http” - hypertext transfer protocol
• "www" - world wide web server name
• “amazon" - second-level domain name
• “com" - top-level domain name
• "books" - directory name • “children" - file name
• "html" - file type

Client-Server

The client-server model is the distributed computing architecture used by most Internet
services, generally classifying hosts on the Internet as clients and servers. Client computers
use client programs to access Internet services provided by host computers (Servers) running
server programs that provide the information or services needed. For example, web browsers
are client programs used to access information hosted by Web Servers. Each Internet service
requires a specific client program; however, most of these services can now be accessed by
simply using a web browser.

6.6 Ways of finding information on the Internet

(a) Net surfing –involves scanning pages and clicking on links randomly. It is a leisurely
way of searching for information which could be highly unorganized and inefficient.
It involves browsing the links provided on the current web page being viewed, in
search of related valuable information
(b) Using a URL – quickest way to find information on the Internet but user must know
where it is located. It is quite effective but user may encounter problems in
remembering the exact URL and in finding the document if the URL has been
changed.
(c) Using search tools and services – can assist user in locating the information desired
among the vast amount of information available on the Net.

6.7 Internet Search Tools and Services

General classifications of Internet tools and services available through the World Wide Web
are

(a) Search engines

Search engines are huge databases of web page files that have been assembled automatically
by the machine over time and are the best means for searching the web. Search engines
compile their databases by employing "spiders" or "robots" ("bots") to crawl through the
Internet, usually using embedded links. They periodically search the World Wide Web and
automatically index and store the information in their database. On the downside, web pages
without links are usually missed in these searches. To circumvent this, most web authors
place tags called META tags on their web pages enabling the search engines to track them.
Search engines are different from each other since they use their own proprietary programs
for searching the Net. These softwares employ different types of indexing as well as
relevancy ranking systems, so searches using different search engines yield different results
in terms of the number of ‘hits’ (matching documents) found and in the actual documents
that comprise those hits.

Examples are: Google - http://www.google.com, Alltheweb - http://www.alltheweb.comand


Altavista - http://www.altavista.com

(b) Subject directories

Subject directories differ from search engines in that most of them are assembled manually.
Much like directories in the print media, subject directories are registries assembled by
editors who determine which sites to include and exclude in their listings. Because of this,
subject directories tend to index even less content than do search engines.

By their very nature, subject directories are more out of date compared to search engines.
Since they do not store actual pages but rather direct to them, it is not uncommon to find that
some of the addresses or search results no longer exist. Their main advantage is that they
point to top-level addresses, and thus are perfect for searching general topics as well as
looking for products and the main sites of commercial establishments.

Examples are; Yahoo - www.yahoo.com , Librarian’s Index – http://www.lii.org, LookSmart


- www.looksmart.com

(c) Invisible Web

The invisible web is so called since it refers to documents that cannot be ordinarily reached
through search engines and subject directories, and are thus ‘invisible’. It is generally
believed to comprise the bulk of the Internet with estimates ranging from 60% to as much as
90% of all content. This content is largely made up of databases, and collections of databases,
that cannot be directly accessed on the Web because they are password protected, hidden or
in formats that are not generally used or searchable. Usually very subject specific, the
invisible Web is organized by professionals or individuals who have accumulated data on
their particular interests. Search engines and subject directories usually exclude them from
main-stream searches since they generate little interest to the bulk of users, but nonetheless
they may still point to places or ‘vortals’ where they can be accessed.

Examples are;Langenberg – http://www.langenberg.com, Complete Planet -


http://www.completeplanet.com , Direct Search -
http://gwis2.circ.gwu.edu/~gprice/direct.htm

(d) Meta-search engines

Meta-search engines send your search query to several search engines simultaneously and
give you a consolidated report of their findings. They do not maintain a database of their
own. Examples are; Metacrawler – http://www.metacrawler.com, Dogpile –
http://www.dogpile.com, ProFusion – http://www.profusion.com
(e) Specialized search engines

Specialized search engines are dedicated to indexing web pages on specific topics .Examples
are;Locate mailing lists and newsgroups, The Lizt – http://www.liszt.com,Mailbase –
http://www.mailbase.ac.uk, Dejanews – http://www.dejanews.com, Google groups -
http://groups.google.com/

(f) Other search tools and services

Others are FTP archives used to locate files on anonymous FTP sites.
Examplesare;ArchiePlex -http://archie.emnet.co.uk/form.html; Web and e-mail people finder
o Ex. – Four11 – http://people.yahoo.com; Multimedia search o Ex. - Webseek -
http://www.ctr.columbia.edu/webseek/; Virtual Reference Libraries – online dictionaries,
indexes, etc. o Ex. Research-it – http://www.iTools.com/research-it and Virtual Reference
Desks – online reference serviceso Ex – AskA+Locator -
http://www.vrd.org/locator/subject.shtml

6.8 Using Internet Tools and Services

Most, if not all of the Internet tools and services can be used through the World Wide Web.
To be able to use the search tools on the Web, one must first know how to use a browser.
Moreover, features and functions of available search tools and services vary and as such one
must be familiar with at least two or more search tools to become effective in finding
information on the Net.

Browsers

These are programs used to access the World Wide Web. A browser allows a user to access
resources on a server and displays the contents of the web in multimedia format. Examples
of browsers are Netscape Navigator, Internet Explorer, America Online, Opera, Firefox,
Safari, etc.

Figure 6.5: Types of Browser.

Using a Browser

You need to be familiar with the features of your web browser and know how to do these;
• enter a URL in the location or address bar to visit a particular web site
• open, resize, close a browser window
• locate and use the navigation tools on your browser, ie., back, reload/refresh, home, print
• identify and use hyperlinks to get around the web
• download documents and files
• use plug-ins like Adobe Acrobat or Macromedia Shockwave

Generally, there are two ways of using search tools and services
 Browsing – usually applied to directories where subjects are arranged hierarchically
 Keyword search – search box is provided for entering keywords to search the
database
• Simple search – search on the keywords, Type keywords in the search box, press
Enter on the keyboard, and then select from the results
• Advanced search – search can be refined using various techniques

Browsing subject directories


From the home page you start with a broad subject area and follow the links to more specific
areas until you reach the subject you wish to explore, and then you click on one of the
displayed results to go to the selected page (document).

6.8 How to find information on the Internet


 Analyze your topic
• What are you searching? For what purpose?
• What type of information do you want?
• The purpose is to determine what terms to use in your search and what search tool
or feature you need to search successfully

 Choose the search tool you need


• Search tools find documents matching your information need
• Every search tool is different. They vary in features and size/comprehensiveness
• The most important features in selecting a search tool are those which allow you to
refine or focus your search when you need to

 Learn how to use the search tools


• Being familiar with most of the major search tools and their capabilities allows you
to zero in on your search
• Learn how to use Boolean logic, phrase searching, truncation, field searching, etc.
• Spend time reading the Help file to know its features and capabilities

 Formulate your search strategy


• Formulating your search strategy beforehand allows you to search for information
systematically
• It also saves you a lot of time and money if you are paying for Internet access by the
minute
• Your search strategy should be based on your information need

 Search with a question in mind


• How am I going to use this?
• Do I have enough or too much information?
• Scan the content of the material to find out if it has anything of value
• Evaluate the website for accuracy and authority

Simple search strategy


• Pick your site
• Learn to use the search tools
• Choose your words carefully
• Vary your spelling
• Know how to widen your search
• Know how to use refining techniques to narrow your search
• Use multiple search engines
• Use meta-search engines
• Use specialized search engines
• Reuse your search

Tips to finding information on the Internet


• Learn the features and functions of your browser
• If you know the URL go directly to it
• Always check for typing errors
• Define the topic in terms of concepts
• Express each concept using keywords, multiple keywords or phrases
• Search multiple terms or exact phrase and not single words
• Read the help screens and search tips
• Utilize two or more search tools
• Use any advanced features of the search engine
• Use services which index quality sites
• Evaluate the results
• Download the information
• Cite your source properly

Problem encountered during searching and their solutions

Problem Solution
Endless links that lead to getting lost Try another search
Data traffic taking eternity to download Try it another time /site or change ISP
Too many; too few or irrelevant sites Refine or vary your search
Information overload Search with a more specific question in mind

6.9 Online Resources

Online resources have made an entire revolution in education, not only because they are
convenient and accessible, but because they make the entire process of teaching and learning
more interesting and memorable. There are free and paid online resources for college
students,and they usually complement one another quite well. Each student will prefer
different resources according to their subjects of interest and learning style, but there are
universally great tools that impress nearly every student who tries them.

In order to help college students locate the best online resources, the underlisted sites may be
useful;

1. The rapid E-learning Blog


This is owned by Tom Kuhlmann who shares practical tips all students can benefit
from. The blog offers up-to-date information on different education-related topics that
will help you become an e-learning pro. The discussions under each post are also very
valuable.
https://blogs.articulate.com/rapid-elearning/
2. Atrixware E-Learning Solution Blog
This is a company that has developed a great online learning management system that
enables students to create great presentations easily. However, the really valuable
resource is the blog section of this website, where you can read fresh information
about the most popular and most useful e-learning tools.
https://www.atrixware.com/blog/wp/
3. Social Media Blogs for college Students at NinjaEssays
NinjaEssays lists useful educative social media tools that will motivate you to learn
new things each day by making the studying process easier and more fun. This is a
very valuable resource that will help you advance your education and improve your
learning skills. With the usage of these tools, the entire classroom will be more
effective and motivated.
4. Saylor
The Saylor Foundation started with a very simple, honest and strong idea: to make
education free for everyone. If you are looking for free classes on all sorts of subjects,
this is the place where you can find them.
https://www.saylor.org/
5. Getting Smart
Getting Smart is one of the most passionate learning-focused communities on the
web. The website will lead you to ways and resources that will increase your studying
effectiveness.
https://www.gettingsmart.com
6. Alison
Alison.com is a website founded with a noble goal: to enable anyone to receive free
education of high quality. All you need is a will to learn new things and this website
will provide you with all necessary tools.
https://alison.com
7. Coursera
This is one of the most valuable learning resources on the web. Students can find free
courses provided by prestigious universities. Almost all courses are offered including;
Humanities, Computer Science, Business, Mathematics, Biology, and more. This
website is necessary for all students who want to expand their knowledge on a subject
or find information they will use for their school projects.
https://www.coursera.org
8. iHomework
This app is available on all Apple devices, so you can access it wherever you are. The
idea behind its concept is to make your life as a student easier. You can use
iHomework to quickly enter important tasks, course information and homework
assignments.
https://www.ihomeworkapp.com/
9. Openculture
The content offered on this website is not only useful for school project, but also
personal intellectual development as well. Open Culture delivers content from many
different topics, from writing tips and literature characters to world history and wars.
One of the greatest benefits of the Internet technology is the easy accessibility to
various types of information. The website listed above can offer great help for all
students who want to advance their knowledge or make the process of studying and
writing papers easier.
www.openculture,com
10. FindTutorials
This website collects useful tutorials from across the web, so literarily contains vast
resourses. The best thing about FindTutorials.com is that the users vote on the quality
of all offered tutorials, so you will know which links are worth clicking on.
https://www.findtutorials.com/

.
CHAPTER SEVEN

BASIC PRINCIPLES OF COMPUTER PROGRAMMING

7.1 What Is Programming?


Programming is the process of taking an algorithm and encoding it into a notation, a
programming language, so that it can be executed by a computer. Although many
programming languages and many different types of computers exist, the important first step
is the need to have the solution. Without an algorithm there can be no program.
Computer science is not the study of programming. Programming, however, is an important
part of what a computer scientist does. Programming is often the way that we create a
representation for our solutions. Therefore, this language representation and the process of
creating it becomes a fundamental part of the discipline. Computer programming is both an art
and a science

The computer is a general-purpose machine with a remarkable ability to process information. It


has many capabilities, and its specific function at any particular time is determined by the user.
This depends on the program loaded into the computer memory being utilized by the user.
There are many types of computer programs. However, the programs designed to convert the
general-purposes computer into a tool for a specific task or applications are called ‘Application
programs’. These are developed by users to solve their peculiar data processing problems.
Computer programming is the act of writing a program which a computer can execute to produce
the desired result. A program is a series of instructions assembled to enable the computer to
carry out a specified procedure. A computer program is the sequence of simple instructions into
which a given problem is reduced and which is in a form the computer can understand, either
directly or after interpretation.

7.2 Programming Methodology


Principles of good Programming
It is generally accepted that a good Computer program should have the characteristics shown
below:
Accuracy: The Program must do what it is supposed to do correctly and must meet the
criteria laid down in its specification.
Reliability: The Program must always do what it is supposed to do, and never crash.
Efficiency: Optimal utilization of resources is essential. The program must use the
available storage space and other resources in such as way that the system speed is not
wasted.
Robustness: The Program should cope with invalid data and not stop without an
indication of the cause of the source of error.
Usability: The Program must be easy enough to use and be well documented.
Maintainability: The Program must be easy to amend having good structuring and
documentation.
Readability: The Code of a program must be well laid out and explained with comments.

7.3 Stages of Programming


The preparation of a computer program involves a set of procedure.
These steps can be classified into eight major stages, viz
(i) Problem Definition
(ii) Devising the method of solution
(iii) Developing the method using suitable aids, e.g. pseudo code or flowchart.
(iv) Writing the instructions in a programming language
(v) Transcribing the instructions into “machine sensible” form
(vi) Debugging the program
(vii) Testing the program
(viii) Documenting all the work involved in producing the program.

(i) Problem definition


The first stage requires a good understand of the problem. The programmer (i.e. the person
writing the program) needs to thoroughly understand what is required of a problem. A
complete and precise unambiguous statement of the problem to be solved must be stated.
This will entail the detailed specification which lays down the input, processes and output-
required.

(ii) Devising the method of solution


The second stage involved is spelling out the detailed algorithm. The use of a computer to
solve problems (be it scientific or business data processing problems) requires that a
procedure or an algorithm be developed for the computer to follow in solving the problem.

(iii) Developing the method of solution


There are several methods for representing or developing methods used in solving a problem.
Examples of such methods are: algorithms, flowcharts, pseudo code, and decision tables.
(iv) Writing the instructions in a programming language
After outlining the method of solving the problem, a proper understanding of the syntax of
the programming language to be used is necessary in order to write the series of instructions
required to get the problem solved.

(v) Transcribing the instructions into machine sensible form


After the program is coded, it is converted into machine sensible form or machine language.
There are some manufacturers written programs that translate users program (source
program) into machine language (object code). These are called translators and instructions
that machines can execute at a go, while interpreters accept a program and executes it line-
by-line.
During translation, the translator carries out syntax check on the source program to detect
errors that may arise from wrong use of the programming language.

(vi) Program debugging


A program seldomly executes successfully the first time. It normally contains a few errors
(bugs). Debugging is the process of locating and correcting errors. There are three classes
of errors.
(i) Syntax errors: Caused by mistake coding (illegal use of a feature of the
programming language).
(ii) Logic errors: Caused by faulty logic in the design of the program. The
program will work but not as intended.
(iii) Execution errors: The program works as intended but illegal input or
other circumstances at run-time makes the program stop. .

(vii) Program testing


The purpose of testing is to determine whether a program consistently produces correct or
expected results. A program is normally tested by executing it with a given set of input data
(called test data), for which correct results are known.
(viii) Program documentation: Documentation of the program should be developed at
every stage of the programming cycle. The following are the advantages of program
documentations
(i) It provides all necessary information for anyone who comes in contact
with the program.
(ii) It helps the supervisor in determining the program’s purpose, how long the
program will be useful and future revision that may be necessary.
(iii) It simplifies program maintenance (revision or updating)
(iv) It provides information as to the use of the program to those unfamiliar
with it.
(v) It provides operating instructions to the computer operator.

7.4 Programming Environment with Animation

7.4.1 Meaning of Scratch


Scratch is a visual programming environment where you design or create your interactive stories,
games & animations. While Scratch has been designed with a typical 3rd or 4th grader in mind,
people of all ages can use it to learn the basics of programming in an enjoyable way! Scratch
involves drag and drop of various blocks together to write programs & such an environment
enables the users to focus on the logic & enjoy the learning experience! Unlike most Java/C++
development environments, there is NO free-form typing, so there are syntax errors either!
Scratch is not limited to young people. People of all ages with no programming experience can
enjoy its simplicity and learn the basics of programming.

Scratch is a visual programming environment that lets users create interactive, media-rich
projects. People have created a wide range of projects with Scratch, including animated stories,
games, online news shows, book reports, greeting cards, music videos, science projects, tutorials,
simulations, and sensor-driven art and music projects. The Scratch application is used to create
projects containing media and scripts. Images and sounds can be imported or created in Scratch
using a built-in paint tool and sound recorder. Programming is done by snapping together
colorful command blocks to control 2-D graphical objects called sprites moving on a background
called the stage. Scratch projects can be saved to the file system or shared on the Scratch Web
site.

7.4.2 Scratch Editor


The Scratch editor has three main parts:
 Stage: Where your program runs. it is the background for the sprite or backdrop.
 Sprite list: A list of the sprites (objects) in your program, because each object is a sprite and
the default sprite is a cat
 Script editor / costume editor: Where you edit your programs or your sprite’s pictures
When the Scripts tab is chosen, the script editor is shown as in figure 7.1

Figure 7.1: Script Editor


The script editor has three main parts:
 Script area: Where you build scripts.
 Block menu: Where you choose the category of blocks (programming statements) to use.
 Block palette: Where you choose the block to use.

When the Costumes tab is chosen, the costume editor is shown in figure 7.2

Figure 7.2: Costume Editor.

When the Block tab is chosen, figure 7.3 will be displayed

Figure 7.3: Block Menu.

When the sound tab is chosen, figure 7.4 will be displayed


Figure 7.4: Sound Menu.

7.4.3 Performing Movement and Loop

(a) Moving Program Name: Square

1. Click File/New to create a new project and enter a project name of Square.
2. From the Events menu, drag a when green flag clicked block to the scripts area. Your scripts
area should look like this:

3. From the Motion menu, drag a goto x: 0 y: 0 block to the scripts area and snap it to the bottom
of the when green flag clicked block. Your script should look like this:

4. Add a move 10 steps block to the bottom of your script and change the 10 to 100.

5. Click the green flag at the top right corner of the stage to run your program. Let’s look at what
happened:
 The when green flag clicked block tells Scratch that the other blocks in the script are to be
executed at the start of the program — that is, when the green flag is clicked.
 The go to x: 0 y: 0 block tells Scratch to move the sprite — that’s the cat, which is what
you’re writing instructions for — to the coordinates (0, 0). The stage has a coordinate system
with (0, 0) in the center, x values ranging from –240 to +240, and y values ranging from –
180 to +180.

 The move 100 steps block tells Scratch to move the sprite 100 units in the direction it is
facing

(b) Turning and Waiting

Now it’s time to make your sprite move in a square.


1. Drag a turn counter clockwise 15 degrees block to the bottom of the script and change
the 15 to 90:
2. Add more blocks until you have four move/turn pairs in your script:

3. Run your program. What happened? Nothing? Actually, the sprite moved in a square,
but so quickly that you couldn’t see it. You can fix that by adding wait 1secs blocks
from the Control menu to the stack:

4. Run your program again. Better? If your sprite is too slow, you can always change the
wait time.
(c) Repeat Loops
Look at your script. One thing that should strike you is that three blocks — move, turn, wait
— are repeated four times. Imagine if you wanted your cat to walk in a square 100 times.
You’d need 1,200 blocks! That’s insane. (Not to mention a lot of work.) Fortunately, there is
an easy way to fix this: the repeat loop.
1. Drag the four sets of move/turn/wait blocks away from the bottom of the script.
2. Drag a repeat 10 block to the bottom of your script and change the 10 to a 4.
3. Drag one set of move/turn/wait blocks inside your repeat block.

The result should look like this:

4. Now run your program. Your sprite still moves in a square, but with far fewer
commands. Repeat loops are an incredibly important programming tool. They allow you
to repeat actions without having to add extra blocks, thus saving lots of work. Use repeat
loops!
(d) More Repeat Loops
You may have noticed that the move block makes your sprite jump from one place to
another. Sometimes, this is what you want. Other times, you might want your sprite to move
smoothly across the screen. One way to do this is to make it move multiple, shorter
distances.
1. Replace the move 100 steps block with a repeat loop that moves the sprite 10 times,
moving 10 steps each time.
2. Remove the wait blocks so that the sprite doesn’t pause. (Remember, we added the wait
blocks only because the sprite moved too fast to see.)
3. Run your program and watch the sprite move more smoothly in a square.
(e) Forever Loops
What if you want to make your cat really, really dizzy? Or just want to do something
forever? There is a special kind of repeat loop for this called a forever loop, which you can
find in the Control menu.
1. Replace the repeat 4 block with a forever block.
2. Run your program and watch your cat go round and round and round and round and ...
(f) Cleanup and Save
You probably have a lot of unused blocks laying around the script area.
1. Drag the unused blocks to the blocks palette to delete them.
2. Click File/Save to save your project.

7.4.4 Conditional Actions and Keyboard Commands


In this section, you will learn to execute actions only under certain conditions. You will also
learn to make your sprite respond to keyboard commands.
(a) If Blocks (Back and Forth)
1. Create a new project (File/New) and name it Back and Forth.
2. Create a script that places the sprite at the center of the stage — the point (0, 0) — and
makes it move 10 steps forever.
3. Run your program. Notice that the sprite gets stuck at the right side of the stage. This is
because Scratch doesn’t ever let sprites go completely off the stage. We would like our
sprite to move back and forth across the stage.
(If your sprite doesn’t do anything at all, make sure you started your script with a when
green flag clicked block.)
4. After the move block, add blocks to create an if x position > 240 then command. You will
need an if ___ then block from the Control menu, a greater-than (>) block from the
Operators menu, and the x position block from the Motion menu. You will also need to enter
the number 240 in the greater- than block. Your blocks should look like this:

5. Inside the if-then block, add a turn counterclockwise 180 degrees block:

This script tells Scratch to check if the x position of the sprite is greater than 240 — that is,
if it is at the right edge of the stage. If so, Scratch rotates the sprite 180 degrees. If not,
nothing happens. (There is also an if-then-else block so you can do something else if the test
condition is false.)
Along with repeat loops, if-then and if-then-else statements are two of the main building
blocks of programs. Use them!
6. Run your program. Your sprite should move to the right edge of the stage, turn around, and
move to the left edge of the stage, where it gets stuck. To fix this, add blocks to rotate the
sprite 180 degrees if the x position is less than –240.
7. Run your program again. Your sprite should move endlessly between the right and left edges
of the stage.
8. To finish your program, keep your cat right side up. (You may have noticed that it is upside
down when moving left.) To do this, add a set rotation style left-right block from the Motion
menu as the first block in your script.
(b) Keyboard Commands
Let’s face it. Walking back and forth is boring. Time to make your sprite jump. To do this,
you will add blocks that move the sprite up and down 50 steps when the space bar is
pressed.
1. From the Events menu, drag a when space key pressed block to the scripts area:

An event is something that happens. The main events in Scratch are starting the program,
pressing keys, and broadcasting and receiving messages, which are used to communicate
between scripts and between sprites.
2. Beneath the key-pressed block, add blocks to move the sprite up and down 50 steps in
increments of 10 steps. You will need to use the change y by 10 block from the Motion
menu.
3. Run your program. When you press the space bar, the sprite should jump up and fall back
down.
(c) Adding More Sprites
Time to give your cat a reason to jump. Really, what cat jumps because you press a space
bar? Lightning is a much better motivator.
1. Click the Choose sprite from library icon:

2. Select the Lightning sprite and click OK. This adds a new sprite to the sprite list.
3. Add a script to hide the Lightning sprite when the program starts. You will need the hide block
from the Looks menu.
4. Add a script to make the Lightning strike the cat when the space bar is pressed. The lightning
sprite should move to the cat sprite, show itself, wait 0.1 seconds, and hide itself again. In
addition to the blocks you have already learned, you will need the go to mouse-pointer block
on the Motion menu — you will need to change mouse-pointer to Sprite1 in the drop-down
list — and the show block from the Looks menu.
5. Run your program, press the space bar, and watch the cat jump.

(d) Adding Sound


To finish the program, add a really good mrowr! When the cat gets zapped.
1. Click Sprite1 in the sprite list and click the Sounds tab.
2. Try the meow sound already there. If you don’t like it, click the speaker icon to choose a
different sound from the sound library.
3. Click the Scripts tab and find the play sound block from the Sound menu. Add this block to
the when space key pressed script. (Select the sound you want from the drop-down list.)
4. Run your program. Zap your cat.

7.4.5 Messages
In this section, you will learn to use messages, which are used to communicate between scripts
and between sprites.
(a) Sending and Receiving Messages
1. Create a new project and name it Taking Turns.
2. Right-click Sprite1 in the sprite list and select duplicate. This will make a copy of Sprite1
named Sprite2.
3. Create a script for Sprite1 that broadcasts the message sprite 1’s turn when the program
starts. You will need the broadcast block in the Events menu. To create your message,
click the drop-down list, select new message..., and type sprite 1’s turn. Your block should
look like this:

4. Drag a when I receive block to the scripts area and set the value to sprite 1’s turn:

5. Add blocks to the when I receive script to glide to a random position, then broadcast a new
message named sprite 2’s turn. You will need the glide 1 secs to x: y: block from the
Motion menu, two pick random 1 to 10 blocks from the Operators menu, and a broadcast
block. Use the random blocks to choose an x value between –240 and 240 and a y value
between –180 and 180.
6. Click Sprite2. Create a script to receive the message sprite 2’s turn, glide to the position of
Sprite1, and broadcast the message sprite 1’s turn. To determine the position of Sprite1, use
__ of __ blocks from the Sensing menu, set as follows:

7. Run your program. Sprite1 should glide to a random position on the stage; Sprite2 should
glide to Sprite1’s position; Sprite1 should glide to a new position; and so on.
Let’s see what’s happening:
a) When the program starts, Sprite1 broadcasts the message sprite 1’s turn.

A message is like yelling into a crowd of people, “Who is supposed to wash the dishes?”
Everybody can hear it, but only those people (sprites) who have been told they are on dish
duty (have a when I receive block for the dish duty message) will respond. This could be
zero, one, many, or all people (sprites).
b) Because Sprite1 has a when I receive block for the message sprite 1’s turn, it executes the
script for that message. In this case, it randomly picks an x value between –240 and +240
and a y value between –180 and +180, then glides to the new position. After gliding, it
broadcasts the message sprite 2’s turn.
c) Because Sprite2 has a when I receive block for the message sprite 2’s turn, it executes the
script for that message. In this case, it finds the x and y coordinates of Sprite1, glides to
that position, and broadcasts the message sprite 1’s turn, starting the cycle all over again.

7.4.6 Animation
(a) Bitmap Mode
Before learning animation, you need to learn about two different ways to draw with a
computer: bitmap drawing and vector drawing. In this section, you will learn about bitmap
drawing.
1. Create a new project and name it Bitmap vs. Vector.
2. Click the Costumes tab and click Clear to delete the cat.
3. Look in the lower right hand corner and make sure you are in Bitmap Mode. If you are
not in Bitmap Mode, click Convert to bitmap.
4. Using the line tool, draw an X with a short and a long arm:

5. Now suppose you want to rotate the short line while keeping the long line in place.
Using the Select tool, select the short line:

6. Using the rotation handle (the circle at the top of the line coming out of the selection
box), rotate the short line:

What happened? Both the short line and a segment of the long line in the selection box
rotated. This is because you didn’t actually select just the short line, you selected
everything in the selection box. In bitmap mode, the computer does not understand what a
line is. Instead, it just stores a grid of dots. For example, this is what the computer stores
for a short line:

(Actually, the computer stores a grid of numbers, where each number tells the computer
what color to draw each dot in the grid. But it’s easier to think of the computer as just
storing a grid of dots.)
Because the computer just stores dots, it doesn’t understand anything about those dots.
That is, it doesn’t realize that the grid shown above is a line, or that a different grid might
show a circle or a triangle. All it sees are dots.
As a result, when you use the select tool, you can’t select a particular line in the grid. You
can only select the dots in the grid. And when you rotate the grid, you rotate all of the dots
in the grid.
(b) Vector Mode
In the section (a), you learned about bitmap drawing. In this lesson, you will learn about
vector drawing:
1. Click Costume2, clear the canvas, and check that you are in Vector Mode. If you are not
in Vector Mode, click Convert to vector.
2. Using the line tool, draw the same lopsided X you drew in the previous lesson.
3. Using the select tool, select the shorter line and rotate it:

What happened? This time, only the shorter line rotated. The reason for this is the
difference between vector graphics and bitmap graphics. In vector graphics, the computer
does not store a grid of bits. Instead, it stores information about the actual objects you
draw.
For example, for a line, it stores the endpoints of the line, as well as the fact that you are
drawing a line. For a circle, it stores the center and radius of the circle, and the fact that you
are drawing a circle.
Because vector graphics store information about individual objects — as opposed to a grid
of dots — you can select, rotate, move, and resize individual objects without affecting
other objects, even if the objects overlap.
In general, you will use vector graphics. Bitmap graphics are useful when creating objects
that can’t easily be described by equations, such as the cat sprite or a photograph.
However, they are more difficult to work with and this class is about writing programs, not
drawing pictures.

(c) Drawing Costumes


Sprites can have different costumes, or graphics, for different actions. For example, a sprite
might use different costumes for walking, running, and jumping. In this lesson, you will
draw four costumes.
1. Create a new project and name it Hiding Man.
2. Click the blue i in the upper left corner of the sprite icon, rename the sprite Hiding Man,
and click the blue triangle to return to the sprite icon.

3. Click the Costumes tab, clear the canvas, make sure you are in Vector Mode, and use
the line and oval tools to draw a simple stick figure of a man walking. Make sure you
use separate lines for the body, arms, and legs. This is because we need to reposition the
arms and legs later.
Don’t spend too much time drawing. We’re learning programming, not fine art.
4. Using the Set costume center tool (the plus sign in the upper right corner of the screen),
set the center of the costume to a point on the “ground” just beneath the man’s feet:

A costume’s center is used for movement and rotation. When you tell a sprite to go to a
certain point, its center goes to that point. When you tell a sprite to rotate, it rotates
around its center.
5. Click costume2 and delete it, then make two copies of costume1. You can use the stamp
tool at the top of the screen, or right click and select duplicate.
6. Click costume2 and use the zoom controls — the plus and minus in the lower right
corner of the screen — to zoom in on your stick man. Rotate and move his arms and
legs:

7. Click costume3 and move the arms and legs again:

8. Finally, click costume2 and duplicate it. You should now have four costumes, with
costume2 and costume 4 being identical:

(d) Simple Animation


Hiding Man (continued) Now it’s time to make your man walk.
1. Click the Scripts tab and create a script that changes to the next costume forever. You
will need the next costume block in the Looks menu:

2. Run your program and watch your man walk in place. If he’s moving too fast, you can
add a wait block after each costume change.
3. After you’re done, delete your forever block. We just used it to show you how
animation works.

7.4.7 Variables
Variables in computing are used to store values. You have already seen some variables. For
example, in the Back and Forth project, you used the variable to determine if the
sprite was near an edge. That is, Scratch stores values in this variables and you can use the value
in your programs. You can also define your own variables and store values in them. For
example, you could use variables to store scores in a game, store the speed of a meteor crashing
to earth (so you know how big a hole to draw when it hits), or calculate the value of y in the
equation y = 3x + 10 for a given value of x.

(a) Numeric Variables (Program Name: Plus 2)


In this section, the user enters a number and the program displays that number plus, minus, and
times 2.
1. Create a new project and name it Plus
2. On the Data menu, click Make a Variable. Name the variable number and click for this sprite
only, then click OK.

Variables can be shared by all sprites or used only by one sprite. is an example
of a variable used by only one sprite: it gives the current x position of that sprite. Other sprites
have their own copies of this variable. is an example of a variable shared
by all sprites — any sprite can use it.

Variables that can be used only by one sprite are called local variables. Variables that can be
used by all sprites are called global variables. As a general rule, you should use local
variables.
3. When the program starts, use ask _______ and wait in the Sensing menu to ask for a number:

4. Scratch stores the number entered by the user in the answer variable from the Sensing menu.
Use the set ______ to ____ block in the Data menu to store the answer in your number
variable:

This is called setting a variable and is a very common thing to do.


5. Now create a local variable called plus2 and set it to the sum of number and 2, using the +
operator from the Operators menu:

6. To show the user what their number plus 2 is, use the say ____ for 2 secs block in the Looks
menu:

7. Run your program, enter a number, and check that the program displays the correct answer.
8. Create local variables to hold the value of the number minus 2 and times 2, set these variables,
and display their values. (Note that the multiplication operator uses an asterisk. This is
because the letter x is commonly used as a variable name; it would be confusing if it also
meant multiplication.)
9. Test your program to make sure it displays the correct values.
It is important to understand that this is a program you could not have written without variables.
Because you did not know what number the user was going to enter, you could not have
computed the value of that number plus, minus, and times 2 without using a variable.

(b) String Variables


In the previous section, you just displayed the user’s number plus, minus, and times 2. It would
be nice to give the user more information. For example:

In fact, this is easy to do.


In the previous section, your variables held numbers. Variables can also hold strings. A string is
a sequence of characters and/or symbols, such as “Your number plus 2 is: 7”, “abc123”, and “I
am a woman”.
1. Create a new local variable called output.
2. After you set the plus2 variable to number + 2, use the join operator in the Operators menu to
set the output variable:

The join operator takes two strings and joins them together. In this case, you are joining the
string “Your number plus 2 is:” and the value of the plus2 variable.
3. Change your say plus2 for 2 secs block to use the output variable:

4. Run your program and check that it works correctly.


5. Modify your program to use the output variable to display the values of the input number
minus 2 and times 2.

(c) Algorithms
Most computer programs use algorithms, which are a set of instructions designed to complete a
certain task, such as tracking the flight of a rotten tomato through the air. It is usually a good idea
to think of your algorithm before you start writing your program. For example, the algorithm for
graphing the points on the line y = 3x + 10 is:
pick a starting value for x
calculate a corresponding value for y using the equation y = 3x + 10
go to (x,y)

repeat some number of times:


increment x
calculate y
go to (x,y)
In this section, you will practice thinking of and programming algorithms.

(d) Sum of the Numbers 1 to n


Suppose someone asked you what the sum of the numbers from 1 to 3 is. Pretty easy: 1 + 2 + 3
equals 6. The sum of the numbers from 1 to 6? A bit harder: 1 + 2 + 3 + 4 + 5 + 6 equals 21.
From 1 to 52? then, it is a time to write a program.
1. Create a new program and name it Sum 1 to n.
2. Create local variables named number, total, and lastValue.
3. Ask the user for a number and set lastValue to that number.
4. Initialize number to 1 and total to 0.
5. Add the following repeat until loop to your script:

This loop adds the numbers from 1 to the number entered by the user. It is important to
understand how it works. Remember that we already set lastValue to the number entered by the
user and initialized number to 1 and total to 0. Suppose the user entered the number 3.

The first time through the loop, number (1) is less than lastValue (3), so we go inside the loop.
 The first block in the loop sets the new value of total to the old value of total (0) plus number
(1). Thus, the new value of total is 0 + 1 = 1.
 The second block in the loop changes the value of number by 1. That is, it adds 1 to the
current value of number. Since the current value of number is 1, the new value is 1 + 1 = 2.
Changing the value of a variable by a fixed amount is called incrementing the variable. It is a
very common operation in loops.

The second time through the loop, number (2) is still less than lastValue (3), so we go inside.
This time, total is set to 1 (old value) + 2 (number) = 3 and number is incremented to 3.

The third time through the loop, number (3) is equal to lastValue (3), so we go inside. total
is set to 3 (old value) + 3 (number) = 6 and number is incremented to 4.

The fourth time through the loop, number (3) is greater than lastValue (3), so we stop.

6. Add blocks to display the output using the string “The sum of the numbers from 1 to n is:
m”, where n is the number entered by the user and m is the total.
7. Test your program.

(e) Sum of the Even/Odd Numbers 1 to n

Now that you’ve seen how to use a loop and variables together, write a program to ask the user
for a number (n) and display the sum of the odd numbers from 1 to n, as well as the sum of the
even numbers from 2 to n. For example, if the user entered the number 6, your program would
display 9 (which is equal to 1 + 3 + 5) and 12 (which is equal to 2 + 4 + 6).

(f) Formula for the Sum of the Numbers 1 to n


It turns out that there is a formula for finding the sum of the numbers from 1 to n: sum of
numbers from 1 to n = n (n + 1) / 2
Write a program to ask the user for a number and use this formula to calculate and display the
sum of the numbers from 1 to the number entered by the user.

You might also like