Anda di halaman 1dari 61

UNIT I

INTRODUCTION

Generation and Classification of Computers- Basic Organization of a Computer –


Number System – Binary – Decimal – Conversion – Problems. Need for logical
analysis and thinking – Algorithm – Pseudo code – Flow Chart

1.1. INTRODUCTION

Nowadays, computers are an integral part of our lives. They are used for the

reservation of tickets for airplanes and railways, payment of telephone and electricity bills,
deposit and withdrawal of money from banks, processing of business data, forecasting of
weather conditions, diagnosis of diseases, searching for information on the Internet, etc.
Computers are also used extensively in schools, universities, organizations, music industry,

movie industry, scientific research, law firms, fashion industry, etc.

The term computer is derived from the word compute. The word compute means
to calculate. Computer performs both simple and complex operations, with speed and
accuracy. Currently, computer literacy involves several aspects. A computer-literate
person knows how to make use of a computer in his or her field to make tasks easier and
to complete them more efficiently. Computer literacy involves knowledge of the Internet

and the World Wide Web and the ability to take advantage of their resources and to
critically judge the information.

Definition:

A computer is an electronic device that accepts data (raw facts) as input,


processes, or alters them in some way and produces useful information as output. A

computer manipulates data by following step-by-step instructions called a program.


Computer performs both simple and complex operations, with speed and accuracy.

A computer is also called as data processor


1 because it can store, process, and
retrieve data, whenever required.
1.2. BASIC OPERATIONS OF A COMPUTER

All computer systems perform the following five basic operations, for converting
raw input data into information:

Input Process Output

Storage

Feedback

i) Input: It is a basic operation of a computer system. This is the process of giving


data and instruction to the computer through the input devices such as
Keyboard, Mouse, etc.,

ii) Process: It is the process of performing arithmetic operations or logical operations


on data to convert them into useful information.

iii) Output: It is the process of producing useful information or results for the user,
such as a printed report or visual display.

iv) Storing: It the process of saving data and instructions to make them readily
available for initial or additional processing, as and when required.

v) Controlling: It is the process of directing the manner and sequence in which all of
the above operations are performed.

2
1.3. CHARACTERISTICS OF A COMPUTER

The computer has many special characteristics which justify its use. A computer can
be used for a variety of tasks including mathematical, logical, architectural and multimedia
applications. The important characteristics of computer are speed, accuracy, automatic,
endurance, versatility, storage, reduction in cost and no IQ.

i) Speed:

A computer is a very fast device. It can perform a task in few milliseconds better

than a human being can do in an entire year. The speed of a computer is measured in
million instructions per second (MIPS). The following are the measurements by which the
speed of a computer is measured.

1 millisecond = 1 x 10-3 second


1 microsecond = 1 x 10-6 second

1 nanosecond = 1 x 10-9 second


1 picosecond = 1 x 10-12 second

Nowadays the speed of a computer is not measured in terms of seconds or milliseconds


but in terms of microseconds, nanoseconds, even in picoseconds.

ii) Accuracy:

In addition to being very fast, computers are very accurate. The accuracy of a
computer is consistently high and the degree of accuracy of a computer depends on its
design. Computer is based on the principle of Garbage-In-Garbage-Out (GIGO). It means
if wrong data is inputted then wrong output will be produced.

3
Example: The computer can accurately give the result o f division o f any two numbers up
to 10 decimal places.

iii) Automatic:

An automatic machine works by itself without human intervention. Computers are


automatic machines because once started on a job, they carry out the job until it is
finished. However, computers being machines cannot start themselves and cannot go out

and find problems and solutions. We need to instruct a computer using coded
instructions that specify how it will do a particular job.

iv) Versatility:

A computer can be used to solve the problems related to various fields. It can
perform different types of tasks with the same ease. At one instance, it may be solving a
complex scientific problem and the very next moment it may be playing a card game.

v) Storage:

Memory is a very important characteristic of computers. A computer has much


more storage capacity than human beings. It can store large amount of data and recall

the stored data even after several years with same accuracy as the data fed. It can store
any type of data such as images, videos, text, audio and many others.

vi) Reduction in cost:

4
The use of computers for data processing in an organization leads to reduction in
paper work and results in speeding up a process. As data in electronic files can be

retrieved as and when required, the problem of maintenance of large number of paper
files gets reduced. Though the initial investment for installing a computer is high but it
substantially reduces the cost of each of its transaction.

vii) No IQ:

A computer has no intelligence on its own. It has to be told what to do and it what
sequence. Hence only the user can determine what tasks a computer will perform. A
computer cannot take its own decision.

1.4. APPLICATIONS OF A COMPUTER

Computers are used in so many fields in our daily life. From Engineers to Doctors,
Students, Teachers, and Government organizations they all use computer to perform

specific tasks, for entertainment or just to finish office work. With greater precision and
accuracy and less time taking computers can do a lot in short time whine doing manually.
Here the applications of computer in various fields are listed below:

i) Business:

A computer has high speed of calculation, diligence, accuracy, reliability, or


versatility which made it an integrated part in all business organizations.

Computer is used in business organizations for:

 Payroll calculations

 Budgeting

 Sales analysis
5
 Financial forecasting

 Managing employees database

 Maintenance of stocks etc.

ii) Banking:

Today banking is almost totally dependent on computer.

Banks provide following facilities:

 Banks provide online accounting facility, which includes current balances,


deposits, overdrafts, interest charges, shares, and trustee records.

 ATM machines are making it even easier for customers to deal with banks.

iii) Insurance:

Insurance companies are keeping all records up-to-date with the help of
computers. The insurance companies, finance houses and stock broking firms are widely
using computers for their concerns.

Insurance companies are maintaining a database of all clients with information showing

 Procedure to continue with policies

 Starting date of the policies

 Next due installment of a policy

 Maturity date

 Bonus

iv) Education:

The computer has provided a lot of facilities in the education system.


6
 The computer provides a tool in the education system known as CBE (Computer
Based Education).

 CBE involves control, delivery, and evaluation of learning.

 The computer education is rapidly increasing the graph of number of computer


students.

 There are number of methods in which educational institutions can use


computer to educate the students.

 It is used to prepare a database about performance of a student and analysis is


carried out on this basis.

v) Marketing:

In marketing, uses of computer are following:

 Advertising - With computers, advertising professionals create art and graphics,


write and revise copy, and print and disseminate ads with the goal of selling
more products.

 At Home Shopping - Home shopping has been made possible through use of
computerized catalogues that provide access to product information and
permit direct entry of orders to be filled by the customers.

vi) Health Care:

Computers have become important part in hospitals, labs, and dispensaries. The
computers are being used in hospitals to keep the record of patients and medicines. It is

7
also used in scanning and diagnosing different diseases. ECG, EEG, Ultrasounds and CT
Scans etc., are also done by computerized machines.

Some major fields of health care in which computers are used are:

 Diagnostic System - Computers are used to collect data and identify cause of
illness.

 Lab-diagnostic System - All tests can be done and reports are prepared by
computer.

 Patient Monitoring System - These are used to check patient's signs for
abnormality such as in Cardiac Arrest, ECG etc.

 Pharma Information System - Computer checks Drug-Labels, Expiry dates,


harmful drug’s side effects etc.

 Surgery - Nowadays, computers are also used in performing surgery.

vii) Engineering Design:

Computers are widely used in engineering purpose.

One of major areas is CAD (Computer aided design). That provides creation and
modification of images. Some fields are:

 Structural Engineering - Requires stress and strain analysis for design of Ships,
Buildings, Budgets, Airplanes etc.

 Industrial Engineering - Computers deal with design, implementation and


improvement of integrated systems of people, materials and equipments.

 Architectural Engineering - Computers help in planning towns, designing


buildings, determining a range of buildings on a site using both 2D and 3D
drawings.
8
viii) Military:

Computers are largely used in defence. Modern tanks, missiles, weapons etc.
Military also employs computerized control systems. Some military areas where a
computer has been used are:

 Missile Control

 Military Communication

 Military Operation and Planning

 Smart Weapons

ix) Communication:

Communication means to convey a message, an idea, a picture or speech that is


received and understood clearly and correctly by the person for whom it is meant for.
Some main areas in this category are:

 E-mail

 Chatting

 Usenet

 FTP

 Telnet

 Video-conferencing

1.5. GENERATIONS OF COMPUTER:

i) First Generation (1946-1959) : Vacuum tubes

9
The period of first generation was 1946-1959. The computers of first generation
used vacuum tubes as the basic components for memory and circuitry for CPU (Central

Processing Unit). These tubes, like electric bulbs, produced a lot of heat and were prone
to frequent fusing of the installations, therefore, were very expensive and could be
afforded only by very large organizations. In this generation mainly batch processing
operating system were used. Punched cards, paper tape, and magnetic tape were used

as input and output devices. The computers in this generation used machine code as
programming language.

Features:

 Vacuum tube technology

 Unreliable
 Supported machine language only
 Very costly
 Generated lot of heat

 Slow input and output devices


 Huge size
 Need of A.C.

 Non-portable
 Consumed lot of electricity

Example: ENIAC, EDVAC, UNIVAC, IBM-701, IBM-650

Advantages:

 That was the only electronic during those old days.


 Those computers were very fast to calculate.

10
 Vacuum tube technology made possible the advent of electronic digital
computers.

Disadvantages:

 It is not really a reliable device.


 No portable
 It is required to be air conditioned.

ii) Second Generation (1959-1965) : Transistors

The period of second generation was 1959-1965. In this


generation transistors were used that were cheaper, consumed

less power, more compact in size, more reliable and faster than
the first generation machines made of vacuum tubes. In this generation, magnetic cores

were used as primary memory and magnetic tape and magnetic disks as secondary
storage devices. In this generation assembly language and high-level programming

languages like FORTRAN, COBOL were used. The computers used batch processing and
multiprogramming operating system.

Features:

 Use of transistors
 Reliable in comparison to first generation computers

 Smaller size as compared to first generation computers


 Generated less heat as compared to first generation computers
 Consumed less electricity as compared to first generation computers
 Faster than first generation computers

11
Example: IBM 1620, IBM 7094, CDC 1604, CDC 3600, UNIVAC 1108

Advantages:

 Smaller in size compared to the first generation of computer


 Used less energy and were not heated as much as the first one
 Better speed and could calculate data in microseconds
 Used faster peripherals

Disadvantages

 Cooling system was required


 Costly and not versatile
 Punch cards were used for input

iii) Third Generation (1965-1971) : Integrated Circuits

The period of third generation was 1965-1971. The


computers of third generation used integrated circuits (IC's) in

place of transistors. A single IC has many transistors, resistors


and capacitors along with the associated circuitry. The IC was
invented by Jack Kilby. This development made computers smaller in size, reliable and
efficient. In this generation remote processing, time-sharing, multi-programming

operating system were used. High-level languages (FORTRAN-II TO IV, COBOL, PASCAL
PL/1, BASIC, F

Features:

 IC used
 More reliable in comparison to previous two generations

12
 Smaller size
 Generated less heat

 A.C needed
 Consumed lesser electricity
 Supported high-level language

Example: IBM-360 series, Honeywell-6000 series, PDP (Personal Data Processor), IBM-

370/168, TDC-316

Advantages:

 Less energy
 Easily portable

 Maintenance cost is low because hardware failures are rare

Disadvantages:

 There are a lot of cases required for air conditioning.


 Highly sophisticated production was easier and cheaper

iv) Fourth Generation (1971-1980): VLSI

The period of fourth generation was 1971-1980. The


computers of fourth generation used Very Large Scale
Integrated (VLSI) circuits. VLSI circuits having about 5000
transistors and other circuit elements and their associated
circuits on a single chip made it possible to have

microcomputers of fourth generation. Fourth generation computers became more


powerful, compact, reliable, and affordable. As a result, it gave rise to personal computer

13
(PC) revolution. In this generation time sharing, real time, networks, distributed operating
system were used. All the high-level languages like C, C++, DBASE etc., were used in this

generation.

Features:

 VLSI technology used


 Very cheap

 Portable and reliable


 Use of PC's
 Very small size
 Pipeline processing

 No A.C. needed
 Concept of internet was introduced

Example: DEC 10, STAR 1000, PDP 11, CRAY-1(Super Computer), CRAY-X-MP(Super
Computer)

Advantages:

 Air conditioning is not required in most cases


 Faster in computation than the last generations

 Heat generated is negligible


 Smallest in size

Disadvantages:

 Highly sophisticated technology required for the manufacture of LSI chips.

v) Fifth Generation (1980 - Till Date): Artificial Intelligence


14
The period of fifth generation is 1980-till date. In the fifth generation, the VLSI
technology became ULSI (Ultra Large Scale Integration) technology, resulting in the

production of microprocessor chips having ten million electronic components. This


generation is based on parallel processing hardware and AI (Artificial Intelligence)
software. AI is an emerging branch in computer science, which interprets means and
method of making computers think like human beings. All the high-level languages like C

and C++, Java, .Net etc., are used in this generation.

AI includes:

 Robotics
 Neural Networks

 Game Playing
 Development of expert systems to make decisions in real life situations.
 Natural language understanding and generation.

Features:

 ULSI technology
 Development of true artificial intelligence
 Development of Natural language processing
 Advancement in Parallel Processing
 Availability of very powerful and compact computers at cheaper rates

Example: Desktop, Laptop, NoteBook, UltraBook, ChromeBook

Advantages:

 It is more reliable and works faster.


 Available in different sizes with unique features
15
ELECTRONIC STORAGE OPERATING SOFTWARE
GENERATION YEAR APPLICATIONS
COMPONENT DEVICE SYSTEM USED

Punched with magnetic drum Machine


FIRST 1946 Vaccum tubes No Simple Business Applications
memory Language

Assembly
SECOND 1959 Transistors Magnetic core, Tapes and Disks No Business, Scientific Research
Language

FORTRAN,
THIRD 1965 Integrated circuits Magnetic Disks Yes BASIC, PASCAL, Business, Scientific Research
C, C++

Dbase, FoxPro,
Engineering Design, Online
FOURTH 1971 Microprocessors Semicondutor memory Yes Oracle, SQL,
Business
etc.,

FIFTH 1980 Artificial Intelligence Compact Disks, Hard Disks Yes 3GL, 4GL, LISP Robotics

16
1.6. CLASSIFICATION OF COMPUTER:

Computers are used for several applications in almost all fields of modern life.
Different types of applications require different types of computers. The digital computers
that are available nowadays vary in their sizes and types. A computer used in a home
differs in size and shape from the computer being used in a hospital. Computers can be
classified:

i. Based on Hardware Design


ii. Based on Purpose

iii. Based on Size and Type

1.6.1. Based on Hardware Design:

Different types of computers process the data in different manner. According to


the hardware design, computers can be classified into three categories:

 Analog
 Digital
 Hybrid

(i) Analog Computer:

The computers which provide us continuous information are called analog


computers. Analog computers are used to process analog data. Analog data is of
continuous nature and which is not discrete or separate. Such type of data includes
temperature, pressure, speed weight, voltage, depth etc. These quantities are continuous
and having an infinite variety of values.

17
These computers are ideal in situations where data can be accepted directly from
measuring instrument without having to convert it into numbers or codes. It measures

continuous changes in some physical quantity.

Example: The Speedometer of a car measures speed, the change of temperature is


measured by a Thermometer, the weight is measured by Weights machine.

Analog computers are widely used for certain specialized engineering and scientific

applications, for calculation and measurement of analog quantities. Analog computers do


not require any storage capability because they measure and compare quantities in a
single operation. Output from an analog computer is generally in the form of readings on
a series of dial (Speedometer of a car) or a graph on strip chart.

(ii) Digital Computer:

A Digital Computer works with digits to represent numerals, letters or other special
symbols. Digital Computers operate on inputs which are ON-OFF type and its output is

also in the form of ON-OFF signal. Normally, an ON is represented by a 1 and an OFF is


represented by a 0. We can say that digital computers process information which is based

on the presence or the absence of an electrical charge or also say as binary 1 or 0.

A digital computer can be used to process numeric as well as non-numeric data. It

can perform arithmetic operations like addition, subtraction, multiplication and division
and also logical operations. Most of the computers available today are digital computers.

Example: Accounting machines and calculators

The results of digital computers are more accurate than the results of analog computers.
We can say that digital computers count and analog computers measures.

18
(iii) Hybrid Computer:

A hybrid is a combination of digital and analog computers. It combines the best


features of both types of computers, i-e. It has the speed of analog computer and the
memory and accuracy of digital computer. Hybrid computers are used mainly in
specialized applications where both kinds of data need to be processed. Therefore, they
help the user, to process both continuous and discrete data.

Example: In hospital Intensive Care Unit (ICU), an analog device is used which measures
patient's blood pressure and temperature etc, which are then converted and displayed in

the form of digits.

1.6.2. Based on Purpose:

Computers are designed for different purposes. Based on the purpose, computers
are classified as

i. General purpose computer


ii. Specific purpose computer

(i) General Purpose Computer:

Most computers in use today are General-Purpose computers. They are built for a
great variety of processing jobs. By using a general purpose computer and different
software, various tasks can be accomplished, including writing and editing (word
processing), manipulating facts in a data base, tracking manufacturing inventory, making
scientific calculations, or even controlling organization’s security system, electricity
consumption, and building temperature.
19
General purpose computers are designed to perform a wide variety of functions
and operations. A general purpose computer is able to perform a wide variety

of operations because it can store and execute different programs in its internal storage.

(ii) Specific Purpose Computer:

A Special-Purpose Computer are designed to be task specific and most of the times
their job is to solve one particular problem. They are also known as dedicated computers,

because they are dedicated to perform a single task over and over again. Such a
computer system would be useful in playing graphic intensive Video Games, traffic lights
control system, navigational system in an aircraft, weather forecasting, satellite launch /
tracking, oil exploration, and in automotive industries, keeping time in a digital watch,

or Robot helicopter.

While a special purpose computer may have many of the same features found in a

general purpose computer, its applicability to a particular problem is a function of its


design rather than to a stored program. The instructions that control it are built directly

into the computer, which makes for a more efficient and effective operation. They
perform only one function and therefore cut down on the amount of memory needed
and also the amount of information which can be input into them. As these computers
have to perform only one task, therefore, they are fast in processing.

1.6.3. Based on Size and Capacity:

Based on physical size, performance and application are, we can divide computers
generally into four major categories:

i. Micro computers
ii. Mini computers

20
iii. Mainframe computer
iv. Super computer

(i) Micro computer:

Microcomputers are small, low-cost and single-user digital computer. They consist
of CPU, input unit, output unit, storage unit and the software. It uses microprocessor as
its CPU. Although microcomputers are stand-alone machines, they can be connected

together to create a network o f computers that can serve more than one user.

Micro computers are typically single-user system but can be used in multi-user
environment either by using Multi-user network operating systems (UNIX, Windows NT)
or LAN (Local Area Network). Microcomputers include desktop computers, notebook

computers or laptop, tablet computer, handheld computer, smart phones and netbook,
etc.,

Types:

(a) Desktop Computer or Personal Computer (PC) - It is the most common type of

microcomputer. It consists of three units—keyboard, monitor, and a system unit


containing the CPU, memory, hard disk drive, etc. It is not very expensive and is suited to
the needs of a single user at home, small business units, and organizations. Apple,

Microsoft, HP, Dell and Lenovo are some of the PC manufacturers.

(b) Notebook Computers or Laptop - They are portable and have all the features of a

desktop computer. The advantage of the laptop is that it is small in size, can be carried
anywhere. Laptops can be placed on the lap while working. Laptops are costlier than the
desktop machines.

21
(c) Netbook - These are smaller notebooks optimized for low weight and low cost, and
are designed for accessing web-based applications. Netbooks deliver the performance

needed to enjoy popular activities like streaming videos or music, emailing, Web surfing
or instant messaging.

(d) Tablet - Tablet Computer has features of the notebook computer but it can accept
input from a stylus or a pen instead of the keyboard or mouse. It is a portable computer.

Tablet computer are the new kind of PCs.

(e) Handheld Computer or Personal Digital Assistant (PDA) - It is a small computer that
can be held on the top of the palm. It is small in size. PDA uses a pen or a stylus for input,
Instead of the keyboard. They have a limited memory and are less powerful. PDAs can be

connected to the Internet via a wireless connection. Example Casio and Apple are some of
the manufacturers of PDA.

(f) Smart Phones - These are cellular phones that function both as a phone and as a small
PC. They may use a stylus or a pen, or may have a small keyboard. They can be

connected to the Internet wirelessly. They are used to access the electronic-mail,
download music, play games, etc. Blackberry, Apple, HTC, Nokia and LG are some of the
manufacturers of smart phones.

(ii) Minicomputer:

Minicomputers are digital computers, generally used in multi-user

systems. Minicomputers are mainly used as small or midrange servers operating business
and scientific applications. They have high processing speed and high storage capacity
than the microcomputers. Minicomputers can support 4–200 users simultaneously. The
users can access the minicomputer through their PCs or terminal.

22
Example: PDP-1, DEC Micro VAX and IBM AS/400

(iii) Mainframe Computers:

Mainframe computers are multi-user, multi-programming and high performance


computers. They operate at a very high speed, have very large storage capacity and can
handle the workload of many users. Mainframe computers are large and powerful
systems generally used in centralized databases. 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. Mainframe computers are used in organizations like
banks or companies, where many people require frequent access to the same data.

Examples: IBM 370, S/390

(iv) Supercomputers:

Supercomputers are the fastest and the most expensive machines. They have high
processing speed compared to other computers. The speed of a supercomputer is
generally measured in FLOPS (Floating point Operations per Second). Some of the faster
supercomputers can perform trillions of calculations per second.

Supercomputers are used for highly calculation-intensive tasks, such as, weather
forecasting, climate research (global warming), molecular research, biological research,
nuclear research and aircraft design. They are also used in major universities, military
agencies and scientific research laboratories.

Example: IBM Roadrunner, IBM Blue gene and Intel ASCI red

Comparison of Micro, Mini, Mainframe and Super Computers:

Computer Main
CPU Speed Word Length No. of Users Example
Type Memory Size
23
Micro Apple-II,
8 to 64KB 100 KIPS 8 bits 1 User
Computer IBMPC Jr
Mini 16MB to 500KIPS to 5 DEC, VAX
Computer 16 to 32 bits 4 to 8 Users
256MB MIPS PDP, IBM

Mainframe 10MB to 32 to 128 DEC-10,


Computer 1 to 5MIPS 32 to 64 bits
256MB Users ICL-9

Super 256MB to Unlimited CRAY-3, NEC


Computer 500MFLOPS 64 to 96 bits
10GB Users SX-11

 KIPS - Kilo Instruction Per Second, MIPS-Million Instructions Per Second, and MFLOP - Million Floating
Point Operations Per Second.
1.7. BASIC ORGANIZATION OF A COMPUTER

A computer is a fast and accurate device, which can accept data, store data,
process them and give, desired results as output. The internal architectural design of
computers differs from one system model to another. However, the basic organization

remains the same for all computer systems. The following are the four basic components
(also called "The functional units") of a computer.

i) Input Unit

ii) Central Processing Unit (CPU)


iii) Output Unit

iv) Memory Unit

24
1. Input Unit:

The input unit of the computer system is used for feeding data and instructions to
the computer. These data and instructions given to the computer are called as input and

the devices used for giving input are called input unit or devices. A computer consists of
an I/O system. It is used by a user to communicate with a computer. For instance, a

keyboard or a mouse may be an input device for a computer, while monitors and printers
are considered output devices for a computer. In computer architecture, the combination

of the CPU and main memory is considered the brain of a computer, and from that point
of view any transfer of information from or to that combination is considered I/O. Hence,

the devices that are used to input data to the computer are called input unit or devices.

Following are few of the important input devices which are used in a computer:

 Keyboard

 Mouse

 Joy Stick

 Light pen

 Scanner
25
 Microphone

 Magnetic Ink Card Reader(MICR)

 Optical Character Reader(OCR)

 Optical Mark Reader(OMR)

Keyboard

Keyboard is the most common and very popular

input device which helps in inputting data to the


computer. The layout of the keyboard is like that of

traditional typewriter, although there are some


additional keys provided for performing additional

functions.

Keyboards are of two sizes 84 keys or 101/102 keys, but now keyboards with 104

keys or 108 keys are also available for Windows and Internet.

Mouse

Mouse is most popular pointing device. It is a very


famous cursor-control device having a small palm size box
with a round ball at its base which senses the movement
of mouse and sends corresponding signals to CPU when
the mouse buttons are pressed.

Generally it has two buttons called left and right button and a wheel is present
between the buttons. Mouse can be used to control the position of cursor on screen, but
it cannot be used to enter text into the computer.

26
Joystick

Joystick is also a pointing device which is used to move

cursor position on a monitor screen. It is a stick having a


spherical ball at its both lower and upper ends. The lower
spherical ball moves in a socket. The joystick can be moved in
all four directions.

The function of joystick is similar to that of a mouse. It is


mainly used in Computer Aided Designing (CAD) and playing computer games.

Light Pen

Light pen is a pointing device which is similar to a pen.

It is used to select a displayed menu item or draw pictures on


the monitor screen. It consists of a photocell and an optical

system placed in a small tube. When the tip of a light pen is


moved over the monitor screen and pen button is pressed, its

photocell sensing element detects the screen location and


sends the corresponding signal to the CPU.

Scanner

Scanner is an input device which works more like a


photocopy machine. It is used when some information is

available on a paper and it is to be transferred to the hard disc


of the computer for further manipulation. Scanner captures
images from the source which are then converted into the

27
digital form that can be stored on the disc. These images can be edited before they are
printed.

Microphone

Microphone is an input device to input sound that is


then stored in digital form. The microphone is used for
various applications like adding sound to a multimedia

presentation or for mixing music.

Magnetic Ink Card Reader (MICR)

MICR input device is generally used in banks because of


a large number of cheques to be processed every day. The

bank's code number and cheque number are printed on the


cheques with a special type of ink that contains particles of

magnetic material that are machine readable. This reading


process is called Magnetic Ink Character Recognition (MICR).

The main advantage of MICR is that it is fast and less error prone.

Optical Character Reader (OCR)

OCR is an input device used to read a printed text. OCR scans

text optically character by character, converts them into a


machine readable code and stores the text on the system

memory.

Optical Mark Reader (OMR)

28
OMR is a special type of optical scanner used to
recognize the type of mark made by pen or pencil. It is used

where one out of a few alternatives is to be selected and


marked. It is specially used for checking the answer sheets of
examinations having multiple choice questions.

2. Central Processing Unit (CPU):

CPU consists of the following features:

 CPU is considered as the brain of the computer.

 CPU performs all types of data processing


operations.

 It stores data, intermediate results and instructions


(program).

 It controls the operation of all parts of computer.

CPU itself has following three components:

a. Memory or Storage Unit

b. Control Unit
c. ALU (Arithmetic Logic Unit)

a. Memory or Storage Unit:

29
This unit can store instructions, data and intermediate results. This unit supplies
information to the other units of the computer when needed. It is also known as internal

storage unit or main memory or primary storage or Random access memory (RAM).

Its size affects speed, power and capability. Primary memory and secondary memory
are two types of memories in the computer. Functions of memory unit are:

 It stores all the data and the instructions required for processing.

 It stores intermediate results of processing.


 It stores final results of processing before these results are released to an output
device.
 All inputs and outputs are transmitted through main memory.

b. Control Unit:

This unit controls the operations of all parts of computer but does not carry out

any actual data processing operations.

Functions:

Functions of this unit are:

 It is responsible for controlling the transfer of data and instructions among


other units of a computer.

 It manages and coordinates all the units of the computer.


 It obtains the instructions from the memory, interprets them, and directs the

operation of the computer.


30
 It communicates with Input/Output devices for transfer of data or results from
storage.

 It does not process or store data.

c. ALU (Arithmetic Logic Unit)

This unit consists of two subsections namely

 Arithmetic section

 Logic Section

Arithmetic Section

Function of arithmetic section is to perform arithmetic operations like addition,


subtraction, multiplication and division. All complex operations are done by making

repetitive use of above operations.

Logic Section

Function of logic section is to perform logic operations such as comparing,


selecting, matching and merging of data.

3. Output Unit:

An output device is any peripheral that receives data from a computer, usually for
display, projection, or physical reproduction. After finishing the processing by the CPU,
the output unit sends results to the user using output devices. These devices take the
machine coded output results from the CPU and convert them into a form which an
human can understand. Following are few of the important output devices which are
used in a computer.

31
(a) Monitors
(b) Graphic Plotter
(c) Printer

a. Monitors:

Monitors, commonly called as Visual Display Unit (VDU), are the main output
device of a computer. It forms images from tiny dots, called pixels that are arranged in a
rectangular form. The sharpness of the image depends upon the number of pixels.
Monitor is made up of small picture elements called pixels. The smaller the pixels, the
better the image clarity, or resolution. It takes more than one illuminated pixel to form
whole character, such as the letter ‘e’ in the word help. The screen can be divided into a
series of character boxes - fixed location on the screen where a standard character can
be placed. Most screens are capable of displaying 80 characters of data horizontally and
25 lines vertically. Two types of monitor are:

CRT LCD

 CRT monitor - Cathode Ray Tube monitor


 LCD monitor - Liquid Crystal Display monitor

(b) Graphic Plotter:


32
A plotter is a computer hardware device much like a printer that is used for
printing vector graphics. Instead of toner, plotters use a pen, pencil, marker, or another
writing tool to draw multiple, continuous lines onto paper rather than a series of dots like
a traditional printer. Though once widely used for computer-aided design, these devices
have more or less been phased out by wide-format printers. Plotters are used to produce
a hard copy of schematics and other similar applications.

(c) Printer:

A printer is an external hardware output device responsible for taking electronic


data stored on a computer or computing device and generating a hard copy of that data.

Printers are one of the most commonly used peripherals on computers and are
commonly used to print text and photos.

Types of printers

Below is a list of all the different types of computer printers. Today, the most
common printers used with a computer are Inkjet and Laser printers.

 3D printer
 All-in-one (AIO) printer
 Dot Matrix printer
 Inkjet printer
 Laser printer
 Multifunction printer (MFP)
 Thermal printer

33
4. Memory Unit:

A memory is just like a human brain. It is used to store data and instructions. Computer
memory is the storage space in computer where data is to be processed and instructions
required for processing are stored. The memory is divided into large number of small
parts called cells. Each location or cell has a unique address which varies from zero to
memory size minus one. For example if computer has 64k words, then this memory unit
has 64 * 1024=65536 memory locations. The address of these locations varies from 0 to
65535. Memory is primarily of three types:

Memory

Primary Secondary

(a) Primary Memory (Main Memory):

Primary memory holds only those data and instructions on which computer is
currently working. It has limited capacity and data is lost when power is switched off. It is

generally made up of semiconductor device. These memories are not as fast as registers.
The data and instruction required to be processed reside in main memory. It is divided

into two subcategories RAM and ROM.

34
Characteristics of Main Memory:

 These are semiconductor memories

 It is known as main memory.


 Usually volatile memory.
 Data is lost in case power is switched off.
 It is working memory of the computer.

 Faster than secondary memories.


 A computer cannot run without primary memory.

(b) Secondary Memory:

This type of memory is also known as external memory or non-volatile. It is slower


than main memory. These are used for storing data/Information permanently. CPU
directly does not access these memories instead they are accessed via input-output
routines. Contents of secondary memories are first transferred to main memory, and then

CPU can access it. For example: disk, CD-ROM, DVD etc.

Characteristic of Secondary Memory:

 These are magnetic and optical memories


 It is known as backup memory
 It is non-volatile memory

 Data is permanently stored even if power is switched


off
 It is used for storage of data in a computer
 Computer may run without secondary memory
 Slower than primary memories

35
Types:

Read Only Memory (ROM):

ROM is permanent memory location that offers huge types of standards to save
data. But it work with read only operation. No data lose happen whenever power failure
occurs during the ROM memory work in computers.

ROM memory has several models such names are following:

1. PROM: Programmable Read Only Memory (PROM) maintains large storage media but
can’t offer the erase features in ROM. This type of RO maintains PROM chips to write
data once and read many. The programs or instructions designed in PROM can’t be

erased by other programs.

2. EPROM : Erasable Programmable Read Only Memory designed for recover the

problems of PROM and ROM. Users can delete the data of EPROM thorough pass on
ultraviolet light and it erases chip is reprogrammed.

3. EEPROM: Electrically Erasable Programmable Read Only Memory similar to the EPROM
but it uses electrical beam for erase the data of ROM.

Comparision between the primary and secondary memory:

Primary memory Secondary memory

The memory devices used for primary The secondary memory devices are
memory are semiconductor memories magnetic and optical memories.

The primary memory is categorized as The secondary memory is always non

36
volatile and non volatile memories, RAM is volatile

the volatile memory and ROM is the non


volatile memory

The primary memory is composed of


The secondary memory is enough capable
programs and data that are presently being
to store huge amount of information
used by the micro processor

Secondary memory is known as additional


Primary memory is known as main memory
memory or back memory

These memories are also called as internal These memories are also called as external

memory memory

Primary memory is temporary The secondary memory is permanent

Commonly used primary memory (main


Generally secondary memories range
memory) available in the range of 512 MB
between 80 GB to 4 TB Hard Disc Drives.
to 8 GB RAMs.

Comparison between RAM and ROM:

Random Access Memory Read Only Memory

RAM allows the computer to ROM stores the program required to


read data quickly to run applications. It initially boot the computer. It only allows
allows reading and writing. reading.

RAM is volatile i.e. its contents are lost It is non-volatile i.e. its contents are

37
when the device is powered off. retained even when the device is powered
off.

The two main types of RAM are static RAM The types of ROM include PROM, EPROM
and dynamic RAM. and EEPROM.

RAM memory is only used to store the ROM memory is used to store permanent
temporary information. information and cannot be deleted.

1.9. NEED FOR LOGICAL ANALYSIS AND THINKING

A Computer can perform wide variety of tasks like receiving data, processing it, and
producing useful results. However, being a machine, the computer cannot perform on its

own. A computer needs to be instructed to perform even a simple task like adding two
numbers. So in order to make computer to complete the task a computer programmer

should give instructions to the computer in the form of computer program.

The goal of a program is to solve a problem or perform a task. Program logic is

used by programmers to model the programming language instructions carried out by


the computer when the program is executed. Think of program logic as instructions you
might give someone on how to make something or perform a task they have never done

before.

Programming language statements are used to implement program logic by

sending instructions to the operating system. It is logic with a program built on program
language statements.

Program:

A program is a set of instructions that


38 instructs a computer how to perform a

specific task. It is written in a high-level language that can be implemented on a


Planning the Logic:

The heart of the programming process lies in planning the program’s logic. During
this phase of the process, the programmer plans the steps of the program, deciding what
steps to include and how to order them. The three most common planning tools are
algorithm, flowcharts and pseudocode.

Coding the program:

After the logic is developed, the programmer can write the source code for a

program. There are hundreds of programming languages are available. A programmer


can choose particular language which is more efficient than others.

Using Software to translate the program in Machine language:

Even though there are many programming languages, each computer knows only
one language that is machine language, which consists of 1s and 0s. Languages like Java

or Visual Basic are available for programmers because someone has written a translator
program that changes the programmer’s English-like high-level programming language

into the low-level machine language that the computer understands.

Data that the


program uses

Write and correct Compile the If no syntax error


Executable
39
the program code program program
If syntax error

List of syntax
Creating an executable program

Problem solving logic

In order to design a program, a programmer must determine three basic steps:

1. The instruction to be performed


2. The order in which those instructions are to be performed

40
3. The data required to perform those instructions

1.10. PROBLEM SOLVING TECHNIQUES (ALGORITHM, FLOWCHART, PSEUDOCODE)

There are different ways of representing the logical steps for finding a solution of a
given problem. They are:

1. Algorithm
2. Flowchart
3. Pseudocode

1.10.1. ALGORITHM:

Algorithm is defined as a step by step procedure for solving any problem. It is a

sequence of finite instructions, used for calculation and data processing to find the
solution for a problem.

Example: To find the addition of three numbers, following algorithm can be used.

Step 1: Start
Step 2: Read three numbers A, B, C
Step 3: Add three numbers and store in SUM
Step 4: Display SUM
Step 5: Stop

Properties of an Algorithm:

 Finiteness: An algorithm terminates after a finite numbers of steps.

41
 Definiteness: Each step in algorithm is unambiguous. This means that the action
specified by the step cannot be interpreted in multiple ways and can be performed
without any confusion.

 Input: An algorithm accepts zero or more inputs

 Output: It produces at least one output.

 Effectiveness: It consists of basic instructions that are realizable. This means that the
instructions can be performed by using the given inputs in a finite amount of time.

Advantages:

 It is easy to understand.

 It has a definite procedure.

 It is easy to develop an algorithm and then convert it into a flowchart and a


computer program.

 It is independent of programming language.

 It is easy to debug as every step is got its own logical sequence.

Disadvantages:

 It is time consuming.

 Inefficient when there is lots of branching from one state.

 Requires large amount of space.

Example: Write an algorithm to find the largest among three different numbers

42
Step 1: Start
Step 2: Declare variables a,b and c
Step 3: Read variables a,b and c
Step 4: If a>b
If a>c
Display a is the largest number
Else
Display c is the largest number
Else
If b>c
Display b is the largest number
Else
Display c is the greatest number
Step 5: Stop

1.10.2. PSEUDOCODE:

Pseudocode is an informal high-level description of the operating principle of


a computer program or other algorithm. Pseudocode is a simple way of writing
programming code in English. Pseudocode is not actual programming language. It uses
short phrases to write code for programs before you actually create it in a specific
language. Once you know what the program is about and how it will function, then you
can use pseudocode to create statements to achieve the required results for your
program.

Guidelines for writing Pseudocode:

1. Write only one statement per line

Each statement in your pseudocode should express just one action for the
computer.
43
Example:

START Program
ENTER two numbers, A, B
ADD the numbers together
PRINT Sum
END Program

2. Capitalize the initial keyword

The initial word of a pseudocode must be in capital

BEGIN
INPUT age
IF age >= “18" THEN
OUTPUT "Eligible for Vote"
ELSE
OUTPUT "Not eligible for Vote"
END IF
END

Keywords:

PROCESS KEYWORD
Input READ, OBRAIN, GET, PROMPT
Output PRINT, DISPLAY, SHOW
Compute COMPUTE, CALCULATE, DETERMINE
Initialize SET, INITIALIZE
Addition INCREMENT
WHILE, DO WHILE, FOR, UNTIL, IF THEN, IF,
Loop
ELSE, IF ELSE, END IF, THEN

44
3. Use standard programming structures

Even if there is no standard for pseudocode, it will be easier for other programmers
to understand your steps if you use structures from existing programming languages.

4. Use blocks to structure steps

Blocks are syntactic tools that tie several instructions together into one instruction.
You can use blocks to order information. steps in Block 1 always come before steps in
Block 2.

Example:

BLOCK1
BLOCK2
BLOCK3
BLOCK2
BLOCK1

5. Keep statements language independent:

Writing of pseudocode should be applicable to any programming languages. The


programmer must be able to convert the pseudocode to any programming languages.

Advantages:

 Since it is language independent, it can be used my most programmers.


 It is easy to develop a program from pseudocode.

 It is compact, reliable and easy to modify.


 Keywords as same like the keywords of programming languages.

Disadvantages:

 It does not provide visual representation of the program


 No standards for writing pseudocode
45
 It cannot be compiled or executed

Example: Write a pseudocode to find the largest among three different numbers

READ x,y,z
SET big=x
IF(y>big)
big=y
END IF
IF(z=big)
big=z
END IF
WRITE big

1.10.3. FLOW CHART:

A flowchart is a schematic representation of an algorithm or a stepwise process.


Flowcharts are used in designing or documenting a process or program. It is a graphical
representation of a process or system that details the sequencing of steps required to
create output. It is a picture of the separate steps of a process in sequential order.

S. No SYMBOL NAME SYMBOL MEANING

Represents sequence of steps and


1 Flow lines
direction of flow

Represents the start and stop of


2 Terminal
the program

Represents either input or output


3 Input/Output

Represents process to be carried


4 Process
out
46
Represents decision making and
5 Decision
branching

6 Connector Used to connect the flowcharts

7 Loop control Used for loop implementation

Used to indicate for function or


8 Predefined process
subroutine names

Represents data stored in outline


9 Store Data storage i.e., secondary storage
devices

Represents data input or output


10 Magnetic Disk
from or to a magnetic disk

Guidelines for preparing flowcharts:

The following are some guidelines in flow charting:

1. In drawing a proper flow chart, all necessary requirements should be listed out in
logical order.

2. The flowchart should be clear, neat and easy to follow. There should not be any
room for ambiguity in understanding the flow chart.

3. The usual direction of the flow of a procedure or system is from left to right or top
to bottom.

4. Only one flow line should come out from a process symbol.

5. 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.

47
6. Only one flow line is used in conjunction with terminal symbol.

7. Write within standard flow chart symbols briefly. As necessary, you can use the
annotation symbol to describe data or computational steps more clearly.

8. 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 if you want to make it
more effective and better way of communication.

9. Ensure that the flowchart has a logical start and finish.

Advantages:

 It provides an easy way of communication because any other person besides the

programmer can understand the way they are represented.

 It provides a clear overview of the entire program and problem and solution.

 It checks the accuracy in logic flow.

 It provides the facility for coding.

 It provides the way of modification of running program.

Limitations:

 Complex logic: When program logic is complicated, the flowchart becomes


complex. This will become a result in waste of time and money trying to correct the

problem.

 Alterations and Modifications: If alterations are required the flowchart may require
re-drawing completely. This will usually waste valuable time.

48
 Reproduction: As the flowchart symbols cannot be typed, reproduction of flowchart
becomes a problem.

Example: Draw a flowchart for addition of two numbers

1.11. PROGRAM CONTROL STRUCTURES

One of the most important aspects of programming is controlling which statement


will execute next. Program control structures enable a programmer to determine the

order in which program statements are executed.

There are three types of program control structures:

(i) Sequence Control Structures


(ii) Selection Control Structures
(iii) Repetition Control Structures

1.11.1 Sequence Control Structures:

49
Sequential means ‘one-after-the-other’. Sequential logic is the
easiest way to construct and follow. You can place each statement in
the order that you want them to be executed and the program
executes them in sequence from the Start statement to the End
statement. Sequential control is the "default" control in the sense that
every statement automatically points to the next statement in the
flowchart diagram. It is based on top-down approach.

1.11.2. Selection Control Structures

It is common that a programmer will need to make a decision about some


condition of program's data to determine whether certain statements should be executed.
A selection control structure allows programmer to make "decisions" in code about the
current state of your program's data and then to take one of two alternative paths to a
"next" statement. All decisions are stated as "yes/no" questions. When a program is
executed, if the answer to a decision is "yes" (or true), then the left branch of control is
taken. If the answer is "no" (or false), then the right branch of control is taken. IF...THEN or
IF..THEN..ELSE or CASE structures are the selection structures.

a) IF...THEN Structure:

This makes a choice between two processes. If the condition is true, then it
performs the process. If the condition is false, then it skips the process.

Pseudocode Flowchart

50
IF (condition) THEN
process 1
....
....
ENDIF

b) IF...THEN...ELSE Structure:

In this structure if the condition is true it executes process 1 else if the condition is
false it executes process 2. In this either the process 1 or process 2 gets executed

depending on the condition.

Pseudocode Flowchart

IF (condition) THEN
process 1
....
....

ELSE
process 2

....
.....
ENDIF

c) CASE Structure:

51
A Case Structure is a branching control mechanism that allows different executions
depending on the value of the label. The Case Structure is analogous to the Case block in

programming language in which, based on what case value the input variable matched,
the case structure will choose the correct cases for execution.

Pseudocode Flowchart

CASE type

Case Type-1:
process 1

Case Type-2:
process 2
....

....
Case Type-n:

process n

1.11.3. Repetition Control Structures:

Repetition statements are called loops, and are used to repeat the same code
multiple times in succession. The number of repetitions is based on criteria defined in the

loop structure, usually a true/false expression. Two types of loop structures are WHILE
and DO..WHILE.

i) WHILE:

52
In this the condition for looping is checked at the beginning of the loop. It is a top
tested loop. If the condition is true the loop will be executed. If the condition is false the
loop will not be executed.

Pseudocode Flowchart

WHILE (condition)
process 1
....
....

END WHILE

ii) DO...WHILE:

In this structure the condition is checked at the bottom. It is a bottom tested loop.
Hence the body of the loop is executed atleast once even if the condition is false.

Pseudocode Flowchart

DO

.....
.....
process 1

....
....

WHILE (condition)

Examples

53
Example 1: Find the area of a triangle

Algorithm Flowchart

Step 1: Start

Step 2: Read the values a,b,c

Step 3: Calculate the three sides of a


triangle s=(a+b+c)/2

Step 4: Find area of a triangle using


area=sqrt(s*(s-a)*(s-b)(s-c))

Step 4: Print area

Step 5: Stop

Example 2: Find average of three numbers.

Algorithm Flowchart

Step 1: Start

Step 2: Read the values n1,n2,n3

Step 3: Calculate the average of numbers


using the formula
Average=(n1+n2+n3)/3

Step 4: Print Average

Step 5: Stop

54
Example 3: Find the given number is leap year or not.

Algorithm Flowchart

Step 1: Start

Step 2: Read the year

Step 3: If (year mod 4)=0 then


print “Leap Year” Else
Print “Not a Leap Year”

Step 4: Stop

Example 4: Find the biggest among three numbers.

Algorithm Flowchart

55
Step 1: Start

Step 2: Read the


values a,b,c

Step 3: If A is greater
than B,
compare it
with C.

Step 4: If A is greater
than C, then
print A is big.

Step 5: If A is not
greater than
B and C, then
compare B
and C.

Step 6: If B is greater
than C print
B is big else
print C is big.

56
Example 5: Find the factorial of a given number.

Algorithm Flowchart

Step 1: Start

Step 2: Read the value Num

Step 3: If Num>1 then calculate


Fact=Fact*Num,
Num=Num-1 else Goto
Step 5.

Step 4: Goto Step 3.

Step 5: Print Fact.

Step 6: Stop

57
Example 6: Find whether the given number is odd or even.

Algorithm Flowchart

Step 1: Start

Step 2: Read the value X

Step 3: If X%2=0 then print EVEN,


else print ODD.

Step 4: Stop

58
Example 7: Find the sum of first N natural numbers.

Algorithm Flowchart

Step 1: Start

Step 2: Read the values N

Step 3: Initialize Sum=0, i=1

Step 4: Calculate Sum=Sum+i

Step 5: If i=N then print Sum else


Goto Step 6

Step 6: Increment the value of i using


i=i+1.

Step 7: Goto to Step 4

59
Example 8: Draw a flow chart to find area and circumference of a circle.

Algorithm Flowchart

Step 1: Start

Step 2: Initialize PI=3.14159

Step 3: Read the radius r

Step 3: Calculate the area and


circumference using the formula
Area=PI*r*r and Circum=2*PI*r

Step 4: Print Area and Circum

Step 5: Stop

60
61

Anda mungkin juga menyukai