Introduction To Computing
Introduction To Computing
Introduction To Computing
[INTRODUCTION TO COMPUTING]
COMPLIDED BY:MR OSAIGBOVO TIMOTHY
CHAPTER 1
WHAT IS A COMPUTER
Computer is an electronic device. It accepts data, processes the data by doing some
mathematical and logical operations and gives us the desired output.
CAPABILITIES OF A COMPUTER
Let us identify the major characteristics of computer.
Speed: computer can work very fast. It takes only few seconds for calculations
that will take hours to complete
Accuracy : In addition to speed, the computer should have accuracy or
correctness in computing. The degree of accuracy of computer is very high and
every calculation is performed with the same accuracy.
Diligence :A computer is free from tiredness, lack of concentration, fatigue, etc. It
can work for hours without creating any error.
Versatility: It means the capacity to perform completely different type of work.
Power of Remembering : Any information can be stored and recalled as long as
you require it.
Storage :The Computer has an in-built memory where it can store a large
amount of data.
LIMITATIONS OF COMPUTERS
Computer is a dumb machine and it cannot do any work without instruction from
the user.
It does not have feelings or emotion, taste, knowledge and experience.
It is very difficult to make a computer act correctly in all situations since a
computer cannot be truly intuitive. Without supervision, computers will operate
poorly when dealing with unexpected circumstances, such as information or
instructions that are incorrect or incomplete.
Many people still prefer to deal with a person rather than a computer. For
example, voice mail and automatic telephone answering machines are often seen
as impersonal, and it can be frustrating hanging on a telephone line without being
able to talk to another person.
Although computers are often used to help with the design process, they are not
capable of original thought.
If the software being used on a computer is poorly written or the user has not
been trained to use the software or the computer correctly, it can become a
hindrance rather than a help.
HISTORY OF COMPUTER
History of computer could be traced back to the effort of man to count large
numbers.
Calculating Machines (1400 BC):The first calculating device called ABACUS was
developed by the Egyptian and Chinese people. The word
ABACUS means calculating board. It consisted of sticks in
horizontal positions on which were inserted sets of pebbles.
2
Napier’s bones :English mathematician John Napier built a mechanical device for
the purpose of multiplication in 1617 A D. The device was known as Napier’s bones.
Slide Rule: English mathematician Edmund Gunter developed the slide rule. This
machine could perform operations like addition, subtraction, multiplication, and
division. It was widely used in Europe in 16th century.
Pascal's Adding and Subtractory Machine: Blaise Pascal developed a machine at
the age of 19 that could add and subtract. The machine consisted of wheels, gears
and cylinders.
Leibniz’s Multiplication and Dividing Machine :The German philosopher and
mathematician Gottfried Leibniz built around 1673 a mechanical device that could
both multiply and divide.
Babbage’s Analytical Engine:It was in the year 1823 that a famous English man
Charles Babbage built a mechanical machine to do complex mathematical
calculations. It was called difference engine. Later he developed a general-purpose
calculating machine called analytical engine. You should know that Charles Babbage
is called the father of computer.
Mechanical and Electrical Calculator :In the beginning of 19th century the
mechanical calculator was developed to perform all sorts of mathematical
calculations. Up to the 1960s it was widely used. Later the rotating part of
mechanical calculator was replaced by electric motor. So it was called the electrical
calculator.
COMPUTER GENERATIONS
The period, during which the evolution of computer took place, can be divided into
five distinct phases known as Generations of Computers. Each phase is
distinguished from others on the basis of the type of technolgy used.
First Generation Computers: First generation computers used Thermion valves.
These computers were large in size and writing programs on them was difficult.
Some of the computers of this generation were:
ENIAC: It was the first electronic computer built in 1946 at University of
Pennsylvania, USA by John Eckert and John Mauchy. It was named Electronic
Numerical Integrator and Calculator (ENIAC).
EDVAC: It stands for Electronic Discrete Variable Automatic Computer and was
developed in 1950. The concept of storing data and instructions inside the computer
was introduced here.
Other Important Computers of First Generation
EDSAC: It stands for Electronic Delay Storage Automatic Computer and was
developed by M.V. Wilkes at Cambridge University in 1949.
UNIVAC: (UNIVersal Automatic Computer), the first electronic computer designed
and sold to solve commercial problems.
Limitations of First Generation Computer
Followings are the major drawbacks of First generation computers.
1. The operating speed was quite slow.
2. Power consumption was very high.
3. It required large space for installation.
3
4. The programming capability was quite low.
Second Generation Computers
Around 1955 a device called Transistor replaced the bulky electric tubes in the first
generation computer. Transistors are smaller than electric tubes and have higher
operating speed. They have no filament and require no heating. Manufacturing cost
was also very low. Thus the size of the computer got reduced considerably.
It is in the second generation that the concept of Central Processing Unit (CPU),
memory, programming language and input and output units were developed.
programming languages such as COBOL, FORTRAN were developed during this
period.
Third Generation Computers
The third generation computers were introduced in 1964. They used Integrated
Circuits (ICs). These ICs are popularly known as Chips. Higher level language such
as BASIC (Beginners All purpose Symbolic Instruction Code) was developed during
this period. Computers of this generations were small in size, low cost, large memory
and processing speed is very high.
Fourth Generation Computers
The present day computers that you see today are the fourth generation computers
that started around 1975. It uses large scale Integrated Circuits (LSIC) built on a
single silicon chip called microprocessors. Due to the development of
microprocessor it is possible to place computer’s central processing unit (CPU) on
single chip. These computers are called microcomputers. Later very large scale
Integrated Circuits (VLSIC) replaced LSICs.
Fifth Generation Computer
The computers of 1990s are said to be Fifth Generation computers. The speed is
extremely high in fifth generation computer. Apart from this it can perform parallel
processing. The concept of Artificial intelligence has been introduced to allow the
computer to take its own decision. It is still in a developmental stage.
CATEGORIES OF COMPUTERS
Broadly they can be divided it to the following categories.
Microcomputer: Microcomputer is at the lowest end of the computer range in terms
of speed and storage capacity. Its CPU is a microprocessor.
Mini Computer: This is designed to support more than one user at a time. It
possesses large storage capacity and operates at a higher speed. The mini
computer is used in multi-user system in which various users can work at the same
time.
Mainframes: These types of computers are generally 32-bit microprocessors. They
operate at very high speed, have very large storage capacity and can handle the
work load of many users.
Supercomputer: They are the fastest and most expensive machines. They have
high processing speed compared to other computers. Supercomputers are mainly
being used for whether forecasting, biomedical research, remote sensing, etc
Examples of supercomputers are CRAY YMP, CRAY2,etc.
4
TYPES OF COMPUTER
We have three different kinds of computers:
i) Analog computers; ii) Digital computers and iii) Hybrid computers
Analog computers: These are devices that measure one form of physical quantities
or another like temperature, pressure, speed and so on. Examples of analog
computers are thermometer, barometer, speedometer and hygrometer
Digital computers: These are devices that are used for counting. Examples include
adding machine, billing machine, electronic wrist-watch and calculator
Hybrid computers: These devices combine the functions of measuring physical
quantities as well as counting. Electronic computers like desktop computers and
notebooks are examples of hybrid computers
SELF TEST 1
1. State six advantages of computers over humans.
2.State four reasons why computers have not completely replaced human experts in
many fields.
3. Describe the classification of computers software. Which of the classification is
used in the following:
i) Fixing a computer infected by computer virus
ii) Preparing a plotter.
4. Explain in brief the various generations in computer technology?
5. Why did the size of computer get reduced in third generation computer?
6. Give short notes on the following
(a) Versatility (b) Storage (c) Slide Rule (d) Babbage’s Analytical Engine
7. Distinguish between Microcomputer and Mainframe computer.
8. What is VLSIC?
9. Who is called the father of Computer Technology.
10.Define the following terms:
i) computer ii) data iii) information iv) program
5
CHAPTER 2
COMPONENTS OF A COMPUTER SYSTEM
Computer Systems are made up of many different parts, for example hardware,
software, processors, memory etc.
Hardware: is any physical part of the computer that you can touch, see and pickup.
Examples of hardware include the monitor, keyboard, mouse, disk drives, printer,
scanner and speakers.
Software: refers to the set of computer programs, that tells the computer what to do.
We can say that it is the collection of programs, which increase the capabilities of the
hardware. Both have to work together to produce meaningful result.
TYPES OF SOFTWARE
Application Software: Application Software is a set of programs to carry out
operations for a specific application. For example, payroll is an application software
for an organization to produce pay slips as an output.
System Software: may be defined as a set of one or more
programs designed to control the operation of computer system.
It is not possible to run application software without system
software. Computer manufactures build and supply this system
software with the computer system. DOS, UNIX and WINDOWS
are some of the widely used system software.
Peripherals:A peripheral is any device which connects to the
computer and exchanges data with the CPU. Examples are:
Monitor, keyboard, mouse, etc
Central Processing Unit (CPU) :The CPU is the 'brain' of the computer. It is where
all the searching, sorting, calculating and decision making takes place.
The speed of the CPU is measured in either Megaherts (MHz) or more commonly
now in Gigahertz (GHz).
CPU Components :You need to have a basic
understanding of the three main parts of a CPU. These
are the: Control Unit; Immediate Access Store;
Arithmetic and Logic Unit (ALU)
The Control Unit
It controls and monitors the hardware attached to the
system It controls the input and output of data
It controls the flow of data within the CPU
The Immediate Access Store
This holds the data and programs needed at that instant by the Control Unit.
The CPU reads data and programs kept on the backing storage and stores them
temporarily in the IAS's memory..
Arithmetic and Logic Unit
This is where the computer processes data either by manipulating it or acting upon it.
It consists of two parts:
6
Arithmetic part - which does exactly what you think it should - it performs the
calculations on the data e.g. 3 + 2 = 5
Logic part - this deals with logic and comparisons. For example, it works out if one
value is greater, less than or equal to another.
MOTHERBOARD
The Motherboard is the central circuit board of your computer. All of the components
and peripherals plug into it. The motherboard houses the ROM chips which store the
BIOS instructions. RAM chips, the CPU, the graphics card, sound card, network
interface card, hard disk and various other external ports and peripherals all attach
directly to it.
DISK DRIVES
The purpose of a disk drive is to read data from a storage device. Common disk
drives that you will come across in your studies are: hard disk drive; removable hard
disk drive; floppy disk drive; zip disk drive ;CD drive ;DVD drive .
INTERNAL MEMORY DEVICES
The two main types of computer internal memory that you need to clearly understand
are Random Access Memory (RAM) and Read Only Memory (ROM)
Read Only Memory (ROM)
Data stored on ROM is not erased when the power is switched
off - it is permanent. This is called 'non volatile memory'.
The ROM chip is used to hold data that cannot be changed by
the user. Instructions related to the operating system are stored
on ROM chips when the computer is manufactured.
This data will usually be the software that tells the computer how to load the
operating system when it is switched on or re-booted.
Random Access Memory (RAM)
In contrast to ROM, RAM is volatile memory. The data is held on a chip, but only
temporarily. The data disappears if the power is switched off.
Have you ever forgotten to save your work before the computer
crashed? When you log back on, your work has disappeared.
This is because it was stored in RAM and was erased when the
PC was switched off. However, if you had saved your work, it
would have been transferred from RAM to the hard disk where it would have been
stored safely.
WHAT ARE REGISTERS?
Registers are temporary memory units that store words. The registers are located in
the processor, instead of in RAM, so data can be accessed and stored faster. The
eight registers in our example are called PC, AC, IR, TIR, +1, AMASK, MAR, and
MBR, and are used as follows:
Registers:
PC: Program Counter. Stores the address of the instruction currently being
executed.
AC Accumulator. Stores a previously calculated value or a value loaded from
the main memory.
7
IR Instruction Register. Stores a copy of the instruction loaded from main
memory.
TIR Temporary Instruction Register. As the CPU evaluates exactly what an
instruction is supposed to do, it stores the edited instruction in the TIR.
1 A constant that represents the number one. The CPU cannot access a
number unless it is in a register or loaded from main memory, or somehow
computed. Therefore this register is set aside to represent this often used
number,
AMASK Address Mask. When the CPU needs to know the address of a target
word that an instruction is using, the AMASK is AND'ed with the instruction to
eliminate the opcode, leaving only the desired address. If that didn't make
sense, leave it to the discussion of instructions later on.
MAR Memory Address Register. This register contains the address of the
place the CPU wants to work with in the main memory. It is directly connected
to the RAM chips on the motherboard.
MBR Memory Buffer Register. This register contains the word that was either
loaded from main memory or that is going to be stored in main memory. It is
also directly connected to the RAM chips on the motherboard.
AUXILIARY STORAGE DEVICES OR SECONDARY STORAGE
Most widely used secondary storage devices are magnetic tapes and magnetic disk.
1. Magnetic Tape: Magnetic tapes are used for large computers like mainframe
computers where large volume of data is stored for a longer time. The cost of storing
data in tapes is inexpensive.
Advantages of Magnetic Tape:
Compact: A 10-inch diameter reel of tape is 2400 feet long and is able to hold 800,
1600 or 6250 characters in each inch of its length. The maximum capacity of such
tape is 180 million characters. Thus data are stored much more compactly on tape.
Economical: The cost of storing characters is very less as compared to other
storage devices.
Fast: Copying of data is easier and fast.
Long term Storage and Re-usability: Magnetic tapes can be used for long term
storage and a tape can be used repeatedly with out loss of data.
Magnetic Disk: Data is stored on both the surface of the disk. Magnetic disks are
most popular for direct access storage device The information stored in a disk can
be read many times without affecting the stored data. So the reading operation is
non-destructive. But if you want to write a new data, then the existing data is erased
from the disk and new data is recorded.
Floppy Disk: It is similar to magnetic disk discussed above.It is cheaper than any
other storage devices and is portable. The floppy is a low cost device particularly
suitable for personal computer system. It is now obsolete.
Optical Disk: It is the necessity to store large volume of data that has led to the
development of optical disk storage medium. Optical disks can be divided into the
following categories:
8
Compact Disk/ Read Only Memory (CD-ROM): CD-ROM disks are made of
reflective metals. Here the storage density is very high, storage cost is very low and
access time is relatively fast. Each disk is approximately 4 1/2 inches in diameter
and can hold over 600 MB of data. As the CD-ROM can be read only we cannot
write or make changes into the data contained in it.
Digital Versatile Disk (DVD) :A DVD is similar to a CD in that it is an optical device
and that a laser is used to store the data and read the data. A single sided DVD can
store about 4.7Gb of data. DVDs which store data on both sides can hold over 9Gb
of data.
Flash Memory :Flash memory storage devices are typically small, lightweight,
removable and rewritable. Memory sticks are available from 1 Gb up to 8 Gb.
Advantages
They are more compact and portable than floppy disks or CDs/DVDs.
They hold more data than a floppy disk and nowadays often more than a CD.
They are more reliable than a floppy disk because they have no moving parts
Disadvantages
At the moment, the cost per megabyte of storage is more expensive than
floppy disks, CDs or DVDs.
They can be easily lost
INPUT DEVICES
These are devices that are used to capture data and send it to a computer.
MANUAL INPUT DEVICES
Keyboard: to enter words and figures.
Touch screen: for making selections by touching the screen.
Mouse: to select icons to run programs or select, drag or move objects.
Tracker ball: For use by people with limited motor skills e.g. people with disabilities
Joystick: Used by a pilot to fly an aeroplane or flight simulator.
Touch Screen: Selecting from a limited list of options
Scanner : Entering hard copy images into a computer
Digital Camera: Taking photographs for input to computers, for input to Photo
printers
Microphone: Recording of voices for presentation software
Web Cams: To input moving pictures from a fixed position into a computer
9
Magnetic Stripe Reader: At POS terminals, ATMs and in security applications
Sensors:are used to detect physical quantities outside a computer such as light,
temperature and pressure.They collect data automatically and usually at regular
intervals. This data is can either be transmitted immediately to the computer or can
be stored for a period of time and a batch of readings sent in one go.
OUTPUT DEVICES
VDU(Visual Display Unit):For quality colour and moving picture display.
Plotters: technical drawings can be output by plotters onto very large display.
Motors:when computers control devices e.g.robots electric motors are often the
output device.
Loudspeakers: computers can make sound through this device.
Buzzers: Automatic cookers, microwave ovens
Heaters: use in automatic washing machines, automatic cookers, etc.
Light Emitting Diodes(LED):use in computer-controlled greenhouses.
OPERATING SYSTEMS
SYSTEM SOFTWARE
Consists of programs that control or maintain the operations of the computer and
its devices.
Serves as interface between the user, the application software, and computer’s
hardware
TYPES OF SYSTEM SOFTWARE:
Utility programs – allows a user to perform maintenance-type tasks, usually related
to managing a computer, its devices or its programs.
Ex. File Manager, Image viewer, personal firewall, uninstaller, disk scanner, disk
defragmenter, diagnostic utility, backup utility, screen saver, antivirus programs
Operating systems
A set of programs containing instructions that coordinate all the activities among
computer hardware resources
Most typical jobs performed by OS are: starting a computer, providing user
interface, managing programs, managing memory, scheduling jobs, configuring
devices, establishing an internet connection, monitoring performance
FUNCTIONS OPERATING SYSTEMS
1. Starting a computer
Booting – the process of starting or restarting a computer
Cold boot – turning on a computer that has been turned-off completely/properly
Warm boot – process of using the operating system to restart a computer
2. Providing user interface:You interact with software through its user interface.
The user interface controls how you enter data and instructions and how information
is displayed on the screen.
3. Managing programs:Single user/multitasking operating systems allow a user to
use more than one program in a computer at one time
4. Managing memory: The purpose of memory management is to optimize the use
of random access memory (RAM).
5. Scheduling jobs: The operating system determines the order in which jobs are
processed.
10
6.Configuring devices:A driver, short for device driver, is a small program that tells
the operating system how to communicate with a specific device
7. Providing file management and other utilities
8. Controlling a network
9.Administering security
Antivirus programs protect the computer against viruses by identifying and removing
any computer virus found in the memory , on storage media, or on incoming files. Ex.
McAfee Virus Scan, Norton Antivirus.
SIGNS OF A VIRUS INFECTION:
An unusual message or image is displayed on the computer screen
An unusual sound or music plays randomly
The available memory is less than what should be available
A program or file suddenly is missing
An unknown program or file mysteriously appear
SELF TEST 2
1. Write True or False:
(a) Secondary memory is called Auxiliary memory.
(b) The magnetic tapes and magnetic disk are primary memories.
(c) A CD-ROM is read only memory.
(d) Mouse is an output device.
(e) Printer is an important output device.
11
2. What are the five basic operations performed by the computer?
3. Choose the correct answer:
(a) The task of performing arithmetic and logical operations is called
(i) ALU (ii) editing (iii) storage (iv) output
(b) The ALU and CU jointly known as
(i) RAM (ii) ROM (iii) CPU (iv) none of the above
(c) The process of producing results from the data for getting useful information
(i) output (ii)input (iii) processing (iv) storage
Which of the following do you think is hardware and which is software (put a tick
in the box you think is correct).
Hardware Software
Keyboard
Floppy Disk
Visual Display Unit
Mouse
Central Processing
Unit
Word Processor
Operating System
Joystick
Spreadsheet
Database
12
CHAPTER 3
TYPES OF COMPUTER PROGRAMMING LANGUAGE AND TRANSLATORS
WHAT IS LANGUAGE?
It is a system of communication between you and me. Some of the basic natural
languages that we are familiar with are English, Hindi, Oriya etc. These are the
languages used to communicate among various categories of persons. But how you
will communicate with your computer. Your computer will not understand any of
these natural languages for transfer of data and instruction. So there are
programming languages specially developed so that you could pass your data and
instructions to the computer to do specific job. You must have heard names like
FORTRAN, BASIC, COBOL etc. These are programming languages. So instructions
or programs are written in a particular language based on the type of job. As an
example, for scientific application FORTRAN and C languages are used. On the
other hand COBOL is used for business applications.
PROGRAMMING LANGUAGES
There are two major types of programming languages. These are Low Level
Languages and High Level Languages. Low Level languages are further divided in to
Machine language and Assembly language.
Low Level Languages
The term low level means closeness to the way in which the machine has been built.
Low level languages are machine oriented.
(a) Machine Language
Machine Language is the only language that is directly understood by the computer.
It does not needs any translator program. We also call it machine code and it is
written as strings of 1's (one) and 0’s (zero).For example, a program instruction may
look like this: 1011000111101.It is not an easy language for you to learn because of
its difficult to understand. It is efficient for the computer but very inefficient for
programmers. It is considered to the first generation language.
Advantage
The only advantage is that program of machine language run very fast because no
translation program is required for the CPU.
Disadvantages
1. It is very difficult to program in machine language. The programmer has to know
details of hardware to write program.
2. The programmer has to remember a lot of codes to write a program which results
in program errors.
3.It is difficult to debug the program.
(b) Assembly Language
13
It is the first step to improve the programming structure. You should know that
computer can handle numbers and letter. Therefore some combination of letters can
be used to substitute for number of machine codes.
The set of symbols and letters forms the Assembly Language and a translator
program is required to translate the Assembly Language to machine language. This
translator program is called `Assembler'. It is considered to be a second-generation
language.
Advantages:
1.The symbolic programming of Assembly Language is easier to understand and
saves a lot of time and effort of the programmer.
2. It is easier to correct errors and modify program instructions.
3. Assembly Language has the same efficiency of execution as the machine level
language. Because this is one-to-one translator between assembly language
program and its corresponding machine language program.
Disadvantages:
1. One of the major disadvantages is that assembly language is machine dependent.
A program written for one computer might not run in other computers with different
hardware configuration.
HIGH LEVEL LANGUAGES
High level languages are simple languages that use English and mathematical symbols
like +, -, %, / etc. for its program construction.
High level languages are problem-oriented languages because the instructions are
suitable for solving a particular problem. There are mathematical oriented languages like
FORTRAN (Formula Translation) and BASIC (Beginners All-purpose Symbolic
Instruction Code) where very large processing is required.
Advantages of High Level Languages
Higher level languages have a major advantage over machine and assembly languages
that higher level languages are easy to learn and use. It is because that they are similar
to the languages used by us in our day to day life.
LANGUAGE TRANSLATOR
ASSEMBLER
An assembler is a program which is used to translate an assembly language program
into machine-level equivalent. The program in assembly language is termed as source
code & its machine language equivalent is called object code.
COMPILER
It is a program translator that translates the instruction of a high level language to
machine language. It is called compiler because it compiles machine language
instructions for every program instructions of higher level language. It scans the entire
program first and then translates it into machine code.
The programs written by the programmer in high level language is called source
program or code. After this program is converted to machine languages by the
compiler it is called object program or code.
Higher Level Language --> (Compile) ---> Program --> Machine Language Program
INTERPRETER
An interpreter is another type of program translator used for translating high level
language into machine language. It takes one statement of high level languages,
14
translate it into machine language and immediately execute it. Translation and execution
are carried out for each statement. The advantage of interpreter compared to compiler is
its fast response to changes in source program. It eliminates the need for a separate
compilation after changes to each program. Interpreters are easy to write and do not
require large memory in computer. The disadvantage of interpreter is that it is time
consuming method because each time a statement in a program is executed then it is
first translated. Thus compiled machine language program runs much faster than an
interpreted program.
SYMBOL MEANING
Oval: Begin/End: A Terminator (begin or end)
15
displays information for the user to access/use)
Rectangle: Process: A Process Box (something has to be
done)
Diamond: Decision: A Decision (choice to be made)
or
e. Only one flow line should enter a decision symbol, but two or three flow lines,
one for each possible answer, should leave the decision symbol.
f. Only one flow line is used in conjunction with terminal symbol.
h. If the flowchart becomes complex, it is better to use connector symbols to
reduce the number of flow lines. Avoid the intersection of flow lines.
i. Ensure that the flowchart has a logical start and finish.
j. It is useful to test the validity of the flowchart by passing through it with a
simple test data.
ADVANTAGES OF USING FLOWCHARTS
The benefits of flowcharts are as follows:
1. Communication: Flowcharts are better way of communicating the logic of a
system to all concerned.
2. Effective analysis: With the help of flowchart, problem can be analyzed in more
effective way.
3. Proper documentation: Program flowcharts serve as a good program
documentation, which is needed for various purposes.
16
4. Efficient Coding: The flowcharts act as a guide or blueprint during the systems
analysis and program development phase.
5. Proper Debugging: The flowchart helps in debugging process.
6. Efficient Program Maintenance: The maintenance of program becomes easy
with the help of flowchart. It helps the programmer to put efforts more efficiently on
that part.
Example of a flowchart:
Problem 1: Write an algorithm and draw the flowchart for finding the average of two
numbers
START
Algorithm:
Input: two numbers x and y
Output: the average of x and y Input x
Steps:
1. input x
2. input y Input y
3. sum = x + y
4. average = sum /2 Sum = x + y
5. output average
Problem 2:
Develop a flowchart to sort Average = sum/2
two numbers in ascending order.
Algorithm:
Steps: Output Average
1. input x
2. input y
3. is x > y? END
4. if yes, display y then x
5. if no, display x then y. PROBLEM 1 PROBLEM 2
SELF TEST 3
1. Differentiate between machine language and Assembly language.
2. Write True or False
a. Low level language and High level language are two major types of programming
languages.
b. Machine language is the only language that is indirectly understood by the
computer.
c. Assembly language is second generation language.
3. What is computer Language?
3. What is machine language? Why is it required?
4. What are advantages and disadvantages of machine language .
5. What is assembly language? What are its advantages over machine languages?
6. What is the difference between source program and object program?
7. What is higher level languages? Why are higher level languages are easier to use.
8. What is compiler? Why is it required?
9. What is interpreter? How does it differ from compiler?
10.Draw a flowchart for a program that input any two numbers. The program compares
the number and reports which one is greater.
11.Develop an algorithm and a flowchart that will compute the area of a triangle.
17
CHAPTER 4
COMPUTER CODES,CHARACTER SETS AND DATABASE
Codes are used to represent the letters and special characters (such as +,-,*,$,&) in
terms of 0’s and 1’s.
CHARACTER SETS
BCD - Binary Coded Decimal: BCD code is the simplest code to represent decimal
numbers. In BCD code a decimal number is represented by four binary bits.For
example, 3 is represented as 0011.
ASCII - American Standard Code for Information Interchange: ASCII is
pronounced as “ask-ee”. It is widely used in micro computers. Micro computers using
8-bit word length use 7-bit to represent the basic code and the 8th bit is used for
parity or it may be permanently 0 or 1.
EBCDIC - Extended Binary Coded Decimal Interchange Code: It is pronounced
as “ebb-see-dick”. It is standard code in large computers. It is an 8-bit code without
parity.
DATABASE
DEFINITION: A database is a collection of data or information which is held together
in an organised or logical way.
Tables
Databases store data or information in tables, just like the one below:
The table allows you to see all of the records stored in the database. Tables can
store many records, from a few dozen for a small database up to millions for a large
company database.
Records
DEFINITION: A record is all of the data or information about one person or one thing.
In the table below, all of the information about each cartoon character is stored in a
'row' or 'record'.
18
Fields
Each table contains a lot of records.
DEFINITION: a 'field' is one piece of data or information about a person or thing.
Data Types
When you are about to set up a database, you need to think about the 'data type'
which you will use for each field.The most common data types are:
Data Types
Data Type Examples
Alphanumeric or Text Forename: James
This allows you to type in text, numbers and Surname: Smith
symbols Address: 73, High
Street
Postcode: CV34
5TR
Car Registration:
EP06 5TV
Telephone Number:
19
01926 123456*
Number 15
This allows a whole number or a decimal number 21.35
Only numbers can be entered, no letters or
symbols
Currency £5.75
This automatically formats the data to have a £ or $54.99
$ or Euro symbol in front of the data and also
ensures there are two decimal places.
Date/Time Long Date: 20
This restricts data entry to 1-31 for day (28 or 30 in February 2006
appropriate months) and 1-12 for month. Medium Date: 20-
It checks that a date can actually exist, for Feb-06
example, it would not allow 31/02/06 to be entered. Short Date: 20/02/06
It formats the data into long, medium or short Long Time: 18:21:35
date/time Medium Time: 06:21
PM
Short Time: 18:21
Autonumber Record 1: 1
This datatype will automatically increase by 1 as Record 2: 2
records are added to the database Record 3: 3
Logical, Boolean, Yes/No Yes/No
This datatype is often referred to as different Male/Female
things, you may hear it called 'logical', or 'boolean' Hot/Cold
or 'yes/no'. On/Off
All it means is that the data is restricted to one of
only two choices
* You would think that 'telephone number' should be a 'number' data type. However
all telephone numbers start with a 0 and you can't put a 0 in front of a 'number' data
type, so telephone number needs to be set as a 'text' data type. Here is a database
table with the different data types set up for you to see:
Primary Key
Every single record in a database has something to uniquely identify it and this is
called the 'Primary Key' or sometimes the 'Key Field'.
20
SELF TEST 4
Give the full forms to the following
1. BCD 2. ASCII 3. EBCDIC 4.
2.Define the following database terms:
1.Database 2. File 3.Records 4.Fields 5.Primary key
CHAPTER FIVE
21
FIGURE 5 Converting a Decimal Number into Its Binary Equivalent
Use the twoB step division/remainder technique to convert a decimal number into an
equivalent number of any base.
Step 1. Divide the number (19, in this example) repeatedly by 2, and record the
remainder of each division. In the first division, 2 goes into 19 nine times with a
remainder of 1. The remainder is always one of the binary digits--0 or 1. In the last
division you divide 1 by the base (2) and the remainder is 1.
Step 2. Rotate the remainders as shown in Figure 5; the result (10011) is the binary
equivalent of a decimal 19.
Figure 6 illustrates how the same division/remainder technique is used to convert a
decimal 453 into its hexadecimal equivalent (1C5). In a decimal- to-hex conversion,
the remainder is always one of the 16 hex digits.
22
FIGURE 7 Converting a Binary Number into Its Decimal Equivalent
Multiply the 1s in a binary number by their position values.
The easiest conversion is binary to hex. To convert binary to hex, simply begin with
the 1s position on the right and segment the binary number into groups of four digits
each (see Figure 8). Refer to the equivalence table in Figure 2, and assign each
group of four binary digits a hex equivalent. Combine your result, and the conversion
is complete.
Hexadecimal to Binary
To convert hex numbers into binary, perform the grouping procedure for converting
binary to hex in reverse (see Figure 8).
23
FIGURE 9 Converting a Hexadecimal Number into Its Decimal Equivalent
As you can see, the only difference in doing arithmetic in the various numbering
systems is the number of digits used.
Examples of Binary Arithmetic
24
Example 3 Subtraction
25
SELF TEST 5
1. 00000000The hex numbering system has a base of ________, and the binary
numbering system has a base of ________.
2. The value of a particular digit in a number is determined by its relative position in
a sequence of digits. (T/F)
3. A single hexadecimal digit can represent how many binary digits: (a) two, (b)
three, or (c) four?
4. The bases of the binary and decimal numbering systems are multiples of 2. (T/F)
5. The binary equivalent of a decimal 255 is ________.
6. The binary equivalent of a hexadecimal 1C is ________.
7. The decimal equivalent of a hexadecimal 1B6 is ________.
8. The hexadecimal equivalent of a decimal 129 is ________.
9. The decimal equivalent of a binary 110101 is ________.
10. The hexadecimal equivalent of a binary 1001 is ________.
26
11. The binary equivalent of a decimal 28 is ________.
12. The binary equivalent of a hexadecimal 35 is ________.
13. The decimal equivalent of a hexadecimal 7 is ________.
14. The hexadecimal equivalent of a decimal 49 is ________.
15. The decimal equivalent of a binary 110110110 is ________.
16. The hexadecimal equivalent of a binary 1110 is ________.
17. The result of 1012 + 112 is ________ (in binary).
18. The result of A116 + BC16 + 1016 is ________ (in hexadecimal).
19. The result of 6010 + F116 - 10010012 is ________ (in decimal).
20. The result of 112 + 278 + 9310 - B16 is ________ (in decimal).
27