0% found this document useful (0 votes)
2 views53 pages

Pari Module1

This document provides an overview of computer fundamentals, including definitions, characteristics, hardware, software, and data processing. It outlines the functional components of a computer, the evolution of computing devices, and the classification of computers based on operation principles and configuration. Additionally, it discusses the generations of computers and their applications in various fields.

Uploaded by

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

Pari Module1

This document provides an overview of computer fundamentals, including definitions, characteristics, hardware, software, and data processing. It outlines the functional components of a computer, the evolution of computing devices, and the classification of computers based on operation principles and configuration. Additionally, it discusses the generations of computers and their applications in various fields.

Uploaded by

btk
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

Chapter 1.

Fundamentals of computers.

Definition: “Computer is an electronic machine that can store, recall and process
data. It can perform tasks or complex calculation according to a set of instructions
or programs.

Characteristics of Computer:

1. Speed:
The computer works very fast. The speed of Computer is measured in terms of MIPS
(Million Instructions per Second) or BIPS (Billion Instructions Per Second).

2. Storage:
The computer can store a large volume of data and information. The storage capacity
of the computer is measured in terms of Bytes. A group of 8 Bits is called a Byte.

3. Accuracy
The computer generated results are exact and without any mistakes with high rate of
consistency.

4. Diligence
Unlike human beings, a computer does not suffer from limitations like tiredness and
lack of concentration. It can work for hours without making any errors.

5. Versatility
Computers are capable of performing any task. Multi-processing features of computer
make it quite versatile in nature. The computer can be adapted to any field easily. It is
used for scientific calculations, business processing, for playing games, teaching, training
etc.

6. Flexibility
Flexibility would involve the number of things you can do with a computer. While
some are best used for simple business tasks, and filing of tasks, others are good for
multimedia, gaming, and so on.

7. Cost effectiveness
Computers reduce the amount of paper work and human effort, thereby reducing costs.

Hardware

The physical parts of a computer system called as hardware. The hardware


components can be seen, touch and feel. The hardware components are fixed inside or
outside the computer system.

Compiled for I.P.U.C by, Keshavamurthy.B.T. Dept of C.S. 1


Example Keyboard, Mouse, Monitor, Printer, RAM, CPU etc.

Software

A Set or collection of programs is known as software. The software is a computer


program written using some computer programming languages to operate the computer.
Software tells the hardware what to do. Unlike hardware, we can’t touch the software.

Example Operating System, TUX Paint, Office Packages, Nudi, Adobe Reader,
Computer Games etc.

The software is broadly classified into two types. They are,

1. System Software: It is a type of software that is designed to control and work with
computer hardware. It acts as a interface between the user, the application software and
hardware.
Example: Microsoft Windows, Linux, DOS etc.

2. Application software: It is a type of Software written by the software developers to


perform a particular task.
Example: Nudi and Ms Office Package etc.

Data

Data is a collection of unprocessed items, which can include text, numbers, audio
or video. Data is the raw information or basic facts that computer can process.
For Example: “PARAM” 16

The computer processed data is called information, which gives particular meaning.
For Example: Name=“PARAM” Age=16.

Functional components of a computer:

Basically any computer is supposed to carry out the following functions.

 Accepts the data and program as input.

 Stores the data, program and retrieve as and when required.

 Process the data as per instructions given by the program and convert it into
useful information.

 Communicate the information as output.

Compiled for I.P.U.C by, Keshavamurthy.B.T. Dept of C.S. 2


Block diagram of a computer

A computer is designed using four basic units. They are:

1. Input Unit
2. Central Processing Unit(CPU)
Control Unit
Arithmetic and Logic Unit (ALU)
3. Memory Unit
4. Output Unit

Input Unit

. The Input Unit basically links the external world or environment to the computer
system. It is a device that allows entering the data and instructions into a computer.

Central Processing Unit (CPU)

It is the main part of a computer system like the heart of a human being. Most
computers are identified by the type of CPU that is present in them. The function of the
CPU is to interpret the instructions in the program and execute them one by one. It
consists of two major units.

Compiled for I.P.U.C by, Keshavamurthy.B.T. Dept of C.S. 3


Control Unit:

It controls and directs the transfer of program instructions and data between
various units. The main activity is to monitor operations of ALU,MU, input and output
devices.

Arithmetic and Logic Unit (ALU):

Arithmetic and Logic Unit performs arithmetic and logical operations and
controls the speed of these operations. Arithmetic operations like addition, subtraction,
multiplication and division (+,-,*, /) and logical operations like AND, OR, NOT and
relational operations like (<,>, <=,>=) are being carried out in this unit.

Memory Unit

The data and the instructions required for processing have to be stored in the
memory unit before the actual processing starts. In a similar manner, the results generated
from processing have to be preserved before it is displayed. The memory units thus
provide space to store input data, intermediate results and the final output generated.

Secondary storage devices are additional memory (storage) devices such as floppy
disks, magnetic tapes, Hard Disk Drive (HDD), Compact Disk (CD), Digital Versatile
Disk (DVD) etc., which are used to store huge information for future use.

Note: The input unit, an output unit, and secondary storage devices are together known as
Peripheral Devices.

Output Unit

It is used to print or display the results, which are stored in the memory unit.
Thus, the output unit links the computer to the outside world. The Monitor and Printer are
the most commonly used output devices.

Evolution of computer:

Abacus:
Around 2500 BC the Chinese invented the Abacus. It was the first machine used
for counting and calculating. It is made of a wooden frame, metal rods, and wooden
beads Abacus was mainly used for addition, subtraction and later for division and
multiplication. Today, the abacus is still used widely in China and other Asian countries
to count and calculate, just as we use calculators.

Napier’s bones:
In the early 17th century, John Napier, a Scottish mathematician, invented
another calculating tool. “Napier’s bones” was based upon manipulation of rods with

Compiled for I.P.U.C by, Keshavamurthy.B.T. Dept of C.S. 4


printed digits. The rods were made of bone, ivory, wood or metal. The set consists of 10
rectangular blocks with multiples of a different digit on each of the four sides.

The slide Rule:


The slide Rule was invented by William Oughtred. It is based on the principle
that actual distance from the starting point of the rule is directly proportional to the
logarithm of the numbers printed on the rule. The slide rule is embodied by the two sets
of scales that are joined together, with a marginal space between them.

Adding Machine-Pascaline:
In 1642, at the age of 19, a French mathematician by the name of Biaise Pascal
invented the Pascaline. The Pascaline is known as the first mechanical and automatic
calculator. The Pascaline was a wooden box that could only add and subtract by means of
a series of gears and wheels. It had a box with eight movable wheels called dials. When
each wheel rotated one revolution, it would then turn the neighboring wheel.

Leibniz Calculator:
Mathematician Gottfried Leibniz built a calculator in 1650 that could
add,substract, multiply and divide the numbers.

Jacquard loom:
In 1801, Joseph Mary Jacquard invented the Jacquard loom. A poweed loom
that used punched wooden cards to automatically weave incredibly detailed patterns
including pictures and text. This can be taken as the first “Read only Memory” device.

Difference and Analytical Engine:


In the early 1820s, an English mathematician by the name Charles Babbage
designed a computing machine called the Difference Engine. This machine was to be
used in the calculating and printing of simple math tables. In the 1830s, he designed a
second computing machine called the Analytical Engine. This machine consisted of five
units, which became the basic principle for the development of modern computer. Hence
Charles Babbage is known as the "Father of Computers”.

1890 AD – Hollerith Tabulating Machine:


In 1889, an American named Herman Hollerith invented a counting machine to
count the population of USA. This electronic machine is able to read the information on
the punched cards and process it electronically. Herman Hollerith was the founder of the
company than became famous as IBM.

Generations of Computer

Depending on the development of the technology the generation of computer is classified


into five generations.

Compiled for I.P.U.C by, Keshavamurthy.B.T. Dept of C.S. 5


First Generation of Computer (1940-1956)
1. The first generation of computers is started with using vacuum tubes as the basic
components.
2. The speed of these computers was very slow, storage capacity was very less and
these computers are large in size.
3. This generation computers operated only on machine language.
4. Input was based on punched card, paper tapes an output was obtained as printout.
Some computers of this generation were ENIAC (Electronic Numerical Integrator
and Calculator), UNIVAC (Universal Automatic Computer).

ENIAC:
It stands for Electrical Numerical Integrator and Computer.
It used a word of ten decimal digits instead of binary ones like previous
automated calculators/computers.

EDVAC
It stands for Electronic Discrete Variable Automatic Computer.
It was to be a vast improvement upon ENIAC. Mauchly and Eckert started
working on it two years before ENIAC even went into operation.
This idea was to have the program for the computer stored inside the computer.

UNIAC
Universal Automatic Computer was the first commercial computer produced in
the United States.

Second Generation of Computer (1956-1963)

In this generation transistors were used in place of vacuum tubes.


These machines were much faster, more reliable than their earlier machines.
It generates less heat and consumed less electricity as compared to first generation
computers.
Second Generation computers used punched cards for input and printout for
output.
This computer moved from the use of machine language to assembly languages.
The computer stored their instructions in their memory, which moved from
magnetic drum to magnetic core technology.

Third Generation of Computer (1964-1971)

In the third generation of computer Integrated Circuits (IC's) were used


in place of transistors.
In this generation, Keyboard and monitors were used instead of punched cards
and printout.
These IC’s were increased the speed of processing and storage capacity.
These computers were more reliable, smaller in size and faster.
Maintenance cost was low comparing to the previous generation and consumed
less electricity.

Compiled for I.P.U.C by, Keshavamurthy.B.T. Dept of C.S. 6


Some computers of this generation were IBM-360 series, Honeywell-6000 series,
PDP(Personal Data Processor), IBM-370/168.

Fourth Generation of Computer (1971-1980)

In the fourth generation of computer, microprocessors were used in place


of Integrated Circuits (IC’s).
The fourth generation of computers is marked by the use of Very Large Scale
Integrated (VLSI) circuits.
This made computers smaller in size became more powerful, they could be linked
to form network.
Some computers of this generation were Mini Computer and Mainframe
computer, Personal computers.

Fifth Generation of Computer (1980-till date)

Fifth generation computer involves the concept of Artificial Intelligence


(AI) which made the computer think like human beings.
This generation uses VLSI (Very Large Scale integration) and ULSI (Ultra Large
Scale Integration) technology.
These computers are more intelligent and faster comparing to other generation
computers.
Types of this generation computers are Desktop, Laptop, Notebook, and Robot.
etc.

Classification of Computer:
Classification based on Principles of Operation:

According to principles of operation computers are classified into three types

1. Analog Computers
2. Digital Computers
3. Hybrid Computers

Analog Computers
Analog computers work upon continuous data. Analog computer operates by
measuring rather than counting. The analog computers are that all calculation takes place
in parallel, hence faster. Modern analog computers usually employ electrical parameters,
such as voltages, resistances or currents, to represent the quantities being manipulated.
Computations are carried out with the physical quantities, such as voltages, length,
current, temperature etc. The devices that measure such quantities are analog devices.
Digital Computer

Compiled for I.P.U.C by, Keshavamurthy.B.T. Dept of C.S. 7


The digital computer works upon discontinuous data. A digital computer operates
on digital data such as numbers. It uses binary number system in which there are only
two digits 0 and 1. Each one is called a bit. They convert the data into digits (Binary Digit
0 and 1) and all operations carried out on these digits at extremely fast rates. A digital
computer basically knows how to count the digits and add the digit. Digital Computers
are much faster than an analog computer and far more accurate. Computers used for
business and scientific applications are digital computers.

Hybrid Computers
Hybrid computer are the combination of both analog and digital computer. They
accept both the analog and digital data for processing. Hybrid computers incorporate the
measuring feature of an analog computer and counting feature of a digital computer.

Hybrid computers are best used in the hospital where the analog part is
responsible for measurement of patient’s heart beat, blood pressure, temperature and
other vital signs and then the operation is carried out in a digital fashion to monitor
patient’s vital signs. Hybrid Computers are also used in weather forecasting.

Classification based on Configuration

Based on the performance, size, cost, capacity, the digital computers are classified into
four types:

1. Micro Computers
2. Mini Computers
3. Mainframe Computers
4. Supercomputers

Micro Computers
Also, know as PC (Personal Computer), it was introduced in [Link] number of
processors in microcomputers will be one or two processors. It contains input devices,
output devices, storage device and processor. The number of processor will be one or
two. It is used by one person at a time.
Example: Desktops (PC, Macintosh), Laptops, Notebooks, Tablets, Palmtops, Smart
Phones.

Uses of Micro computers


They are used in offices or even in homes.They are also used for business and
engineering applications.

Mini Computers:
Mini computers were introduced in the 1960’[Link] is larger and more
powerful than personal computer. It can execute five million instructions per second. It
generally consists of two or more processors. Minicomputer can serve up to 4000
connected users simultaneously. It is normally accessed by users via personal computer
or terminal. A device with a monitor and keyboard is called terminal. It is also known as
dumb terminal. It has no processing power and cannot work as stand-alone computer.

Compiled for I.P.U.C by, Keshavamurthy.B.T. Dept of C.S. 8


Example: Digital Alpha, VAX-800, AS 400

Uses of Mini computers


They are often used by small and medium sized companies to provide centralized store
of information.
They are used for data processing.

Mainframe Computers:

1. Mainframe computers were introduced in 1975.


2. It is very large computer in size.
3. It is more powerful than mini computers and consists of multiple processors.
4. It is designed to perform multiple tasks for multiple users at the same time.
5. The user access a mainframe computer through personal computer.

6. It can execute 16 million instructions per second.


Example: CDC 6600, NEC 610, DEC 10

Uses of Mainframe Computers


Mainframe computers are used in large organizations.
They have large storage capacity.
*It is used in client server environment.
.

Supercomputers:

Supercomputers were introduced in 1980. Super computer is the fastest computer.


Supercomputer is the biggest in size and the most expensive in price than any other
computers. Supercomputer is the most sophisticated, complex and advance computer. It
has a very large storage capacity. It can process trillions of instructions in one second.
Supercomputers are used for highly calculations intensive task. Supercomputers are
designed for ultra-high performance tasks such as weather analysis, encryption cracking,
and the creation of animation.

Example: IBM Roadrunner, IBM Blue Gene etc.

Uses of Supercomputers:
Weather Forecasting
Animated Graphics like Hollywood Movies
Nuclear energy research
Space Science
Weapons and Missile design
Applications of computers:

Compiled for I.P.U.C by, Keshavamurthy.B.T. Dept of C.S. 9


Schools and colleges
Banks
Office
Stock control in business firms
Stock exchange
Research and developments
Entertainment and news
Government office
Satellite communication
Publishing
Travel
Computer-aided manufacturing (CAM)
 Hospital.

Chapter-2

Compiled for I.P.U.C by, Keshavamurthy.B.T. Dept of C.S. 10


Input ,output,memory devices.

INPUT DEVICE:

A computer has several input device namely, Keyboard, Mouse, Trackball,


Joystick, Scanner, Input devices are capable of converting data into a form which can be
recognized by computer. An input device is used to feed data into computer.

Example for Input Device: Light pen, Bar Code Reader, OCR, OMR, MICR etc.

Keyboard

In computing, a keyboard is a typewriter-style device, which uses an


arrangement of buttons or keys, to act as mechanical levers or electronic switches.
Following the decline of punch cards and paper tape, interaction via teleprinter-style
keyboards became the main input device for computers.

A keyboard typically has characters engraved or printed on the keys and each
press of a key typically corresponds to a single written symbol.

The special keys perform specific tasks. Some of the special keys on the keyboard
are. Enter or return key. Tab key, alt key ctrl or control key, del key, insert key, shift key.
Num lock key caps lock key and so on.

Types of keyboard:

1. Standard keyboard: The standard keyboards have their basic layout. The average
number of keys on a regular keyboard is 105/108; QWERTY keyboards are the most
common and have the six alphabets Q, W, E, R, T, and Y in the first row.

2. Ergonomics: It refers to study of method that can reduce stress on muscles to avoid
repetitive strain injury. It mostly deals with optimizing posture and technique while
working, so the work can be carried out in the easiest manner.

3. Wireless keyboard: It is a keyboard that does not need to connect to the computer via a
wire. This makes very convenient for the use the keyboard comfortably. Wireless
keyboard use Bluetooth, Infrared (IR) to connect to the computer.

4. Virtual keyboard: It is a software device that led to use input data just like hardware
keyboard. They open up as an application and can be controlled by a mouse or wire touch
screen.

5. Compact keyboard: These keyboards are slim and usually do not have the numerical
keypad that is present on the right side of the keyboard these are typically used in laptops.

Mouse

Compiled for I.P.U.C by, Keshavamurthy.B.T. Dept of C.S. 11


It is a pointing device. It is palm sized input device. Contains ball under it, the
movement of ball moves the pointer on the screen. There are three types of mice. 1.
Mechanical [Link] 3. Optical.

Mechanical: This mouse has a small rubber ball underneath that moves against
two rollers as it passes across a flat surface. Mechanical sensors detect the movement of
the rollers as x and y axis and the cursor on the screen moves accordingly.

Optomechanical: As the rollers have wheels on the end of them with evenly
spaced holes. As the wheels spin, a light sensitive optical device counts number of holes
that pass and convert those numbers to an x and y-axis.

Optical: This mouse more accurate or precise and has no moving parts. It uses
the laser to detect movement and has to be paired with special mat.

JOYSTICK:

A joystick is an input device consisting of a stick that pivots on a base and reports
its angle or: The joystick can be moved in all four directions. The function of the
joystick is similar to that of a direction to the device it is controlling. Joysticks are also
used for controlling machines such as cranes, trucks, underwater unmanned. It is mainly
used in playing computer games.

SCANNER: The scanner captures images from the source which are then converted
into the digital form for further manipulation.

Devices using Optical media

Optical Mark Recognition (OMR) is the technology of electronically


extracting intended data from marked fields, such as checkboxes and fill-in fields, on
printed [Link] technology scans a printed form and reads predefined positions and
records where marks are made on the form. This technology is useful for applications in
which large numbers of hand-filled forms need to be processed quickly and with great
accuracy, such as surveys, reply cards, questionnaires, academic testing and ballots. A
common OMR application is the use of "bubble sheets" for multiple-choice tests used by
schools. The student indicates the answer on the test by filling in the corresponding
bubble, and the form is fed through an optical mark reader

Optical Character Recognition (OCR)refers to the technology that


involves reading text from paper and translating the images into a form that the Computer
can manipulate (for example, into ASCII codes). An OCR system enables you to take a
book or a magazine article, and feed it directly into an electronic computer file.

Magnetic ink character recognition, or MICR, is a character


recognition technology used primarily by the banking industry to facilitate the processing

Compiled for I.P.U.C by, Keshavamurthy.B.T. Dept of C.S. 12


and clearance of cheques and other document. The MICR encoding, called the MICR
line, is located at the bottom of a cheque or other voucher and typically includes the
document type indicator. The technology allows MICR readers to scan and read the
information directly into a data collection device. Unlike barcodes or similar
technologies, MICR characters can be easily read by humans. The MICR E-13B font has
been adopted as the international standard in ISO 1004:1995.

Monitor or display unit

A monitor or display (sometimes called a visual display unit) is an electronic


visual display for computers. The monitor comprises the display device, circuitry, and an
enclosure. The display device in modern monitors is typically a thin film transistor liquid
crystal display (TFT-LCD) thin panel, while older monitors use a cathode ray tube about
as deep as the screen size.

Resolution refers to the number of dots displayed in the x and y coordinates.


Another term used in the monitor is refresh rate. This refers to the number of times per
second that the image is drawn on the monitor screen. In the graphics mode the screen id
treated as an array of tiny dots called pixels. To support graphics we can have different
resolutions.

PRINTERS:

A printer is an output device that prints characters, symbols, and perhaps graphics
on paper. The printed output is generally referred to as hardcopy because it is in
relatively permanent form. Softcopy refers to temporary images such as those displayed
on a monitor. Printers can be divided into two main categories:

The two main types of printer namely;

1. Impact Printers
2. Non Impact Printers.

Impact printers use a print head containing a number of metal pins, which strike an inked
ribbon. It includes printers that print by striking device against inked ribbon. Impact
printers, Line printers, dot-matrix printers are some of the impact printers.

Characteristics of Impact Printers :

1. In impact printers, there is physical contact with the paper to produce an image.
2. Due to being robust and low cost, they are useful for bulk printing.
3. Impact printers are ideal for printing multiple copies because they can easily print
through many layers of papers.

Compiled for I.P.U.C by, Keshavamurthy.B.T. Dept of C.S. 13


4. Due to its striking activity, impact printers are very noisy.

Line printer:

It can print large volume of text data very fast compared to the other printers. The
print quality is low and they are noisy to operate. The limitations of line printers are they
can print only one font, they can’t print graphics. A line printer can print 150 lines to
3000 lines per minute. Line printers are high speed printers capable of printing an entire
line at a time.

Dot matrix printer:

It uses multi part stationeries to prepare copies of a document. The printing speed
is around 300 characters per second. They are similar to typewriters. They are normally
slow. It prints one line of 8 or 14 points at a time, with print head moving across a line.
The most popular serial printer is the dot matrix printer.

Non impact printer:

The ink or semi-solid ink is stored in the printer cartridges and the flow of ink is
controlled by the processor. The impact printer don’t use striking device. It is much
faster and can print color, different font and size also.

Characteristics of non-impact printers:

1. These printers produce high quality graphics.


2. These printers usually support the transparencies.
3. Measured in dots pen inches.
4. The speed is calculated by the number of pages per minute (PPM).

Laser printers

Laser Printer is a page printer and utilizes a laser beam to produce an image on a
drum. The light of the laser alters the electrical charge on the drum wherever it hits. The
drum is then rolled through a reservoir of toner, which is picked up by the charged
portions of the drum. Finally, the toner is transferred to the paper through a combination
of heat and pressure. This is also the way copy machines work. Because an entire page is
transmitted to a drum before the toner is applied, laser printers are sometimes called page
printers. One of the chief characteristics of laser printers is their resolution – how many
dots per inch (dpi) they lay down. The available resolutions range from 300 dpi at the low
end to 1,200 dpi at the high end

Because laser printers are non-impact printers, they are much quieter than dot
matrix or daisy-wheel printers. They are also relatively fast, although not as fast as some
dot matrix or daisy-wheel printers. The speed of laser printers ranges from about 4 to 20

Compiled for I.P.U.C by, Keshavamurthy.B.T. Dept of C.S. 14


pages of text per minute (ppm). A typical rate of 6ppm is equivalent to about 40
characters per second (cps).

Ink-Jet Printer: It prints characters by spraying patterns of ink on the paper from a
nozzle or jet. It prints from nozzles having very fine holes, from which a specially made
ink is pumped out to create various letters and shapes. The ink comes out of the nozzle in
a form of vapors. After passing through a reflecting plate, it forms the desired letter/shape
at the desired place.

Plotter

A plotter is a special type of printer. It produces images on the paper. It is used to


print large images. It is used CAD system to print large engineering plans and images.
There are many types available. They are pen plotter, Ink jet plotter, electrostatic plotter,
and thermal plotter.

Speaker

It is an output device, which converts audio signals into sound. The sound signals
from analog/ digital are converted in to audible frequency in the speakers and produce
voice output [audio data].

Computer memory

Computer memory is divided into two categories.


1. Primary memory
2. Secondary memory

Primary memory: It is divided into two. They are,

ROM (read only memory)


RAM (random access memory).

RAM: it is called as main memory of computer. It has random accessing property. It is


volatile memory. The information written into it is retained in it as long as the power
supply is on. As soon as the power supply goes of its information is lost. There are two
types of RAM

1. Static RAM- Retains information as long as the power supply is on. It is costlier.
2. Dynamic RAM- it loses its information in a very short time (a few milliseconds)
even though the supply is on. It is to be refreshed periodically. It is cheaper.

ROM (Read only memory)

Compiled for I.P.U.C by, Keshavamurthy.B.T. Dept of C.S. 15


It is nonvolatile in nature. The information is not lost even the power supply goes off. It
also possesses the random access property. The information is stored permanently on the
ROM chip. The various types of ROM are,

PROM- Programmable ROM: The user can store permanent programs, data or any other
kind of information in a PROM. The information can be written only once.

EPROM-Erasable PROM: Exposing to a high intensity ultraviolet light for about 20


minutes can erase the stored data in EPROM. It is cheap compared to PROM.

EEPROM- Electrically Erasable Programmable ROM: It can be programmed through


the use of special electrical pulses. It is possible to integrate the circuit into the computer.

Secondary memory

Secondary memory devices have large storage capacity when compared to


primary memory. This memory is very slow compared to primary. The information,
which is not being processed, is kept in the secondary memory The information which is
need for execution is transformed from secondary memory to main memory. secondary
memory is used for bulk storage data. Ex: Magnetic disk, Hard disk, Floppy disk,
Optical disk, CD rom.

Magnetic disks

Magnetic disks are thin circular plastic plates on which some magnetic material is
coated; the appearance is somewhat similar to a gramophone plate. Magnetic disks come
in various sizes and materials. They use the properties of magnetism to store the data on a
magnetic surface.

In a disk plate information is stored on both surfaces .The surface is further


divided into a number of invisible concentric circles called as tracks. The tracks are
further divided into various sections called as sectors. The information can be read any
number of times.

Hard disk

A hard disk drive (HDD) also hard drive or hard disk is a non-volatile. The hard disk is
the primary storage unit of the Computer. A hard disk consists of a stack of disk platters
that are made up of aluminum alloy of glass coated with a magnetic material.
The surface of a disk is divided into imaginary tracks and sectors. Tracks are
concentric circles where the data is stored. These tracks are numbered from the outermost
ring to the innermost ring, starting from zero. Disk sectors refer to the number of fixed
size areas that can be accessed by one of the disk drive’s read/write heads, in one rotation
of the disk, without the head having to change its position
The time taken to access a particular block consists of
1. Seek time- time to move heads to the right track.

Compiled for I.P.U.C by, Keshavamurthy.B.T. Dept of C.S. 16


2. Latency time- time waiting for sector to come round the head
3. Transfer time-time to transfer the data

Floppy disk

Floppy disk contains a single flat piece of circular plastic plate coated with metal oxide
and enclosed in vinyl or plastic cover. Disks are available in various sizes. Its capacity is
1.44MB. These are cheap when compared to other storage devices.

Optical disk:

An optical disc is a flat piece of circular polycarbonate plastic containing a non-


volatile recording medium that stores digital information. Data is then accessed with a
laser diode illuminating on its recording medium.

To date, many forms of optical disc have been developed. Each generally enjoys a
span of popularity of use before newer discs with greater capacity and capability are
introduced into the market.

CD-ROM

It is a read only optical storage medium capable of holding 682MB of data. Its
data storing capacity is more compared to floppy disk. To read CD-ROM, a CD-ROM
drive is needed. Any information can be written and erased using CD-writer. There are
two types of CD-ROMs.

CD-R: Data once written cannot be erased. It is written once and can be read again and
again.

CD-RW: this disk allows the user to erase previously recorded information and then
record new information onto the same physical location on the disk.

Blue ray disk:

It is referred as BD. It consists of a thickness of 1.1mm of the recording layer. it can store
23 to 27GB of data. Blue violet colored laser beam is used to read and write the data.

Cache memory:

The cache memory is placed in-between the CPU and the main memory. it is
much faster than the main memory. Its access time is much less compared to that of the
main memory. The cache is an intermediate memory and is not accessible to users. It
stores information and data, which are to be immediately executed. It is used to reduce
the average access time reading data, which are normally stored in the main memory.

Compiled for I.P.U.C by, Keshavamurthy.B.T. Dept of C.S. 17


There are two types L1 and L2 where Li lies inside the cpu and L2 lies on the mother
board.

Chapter 3

Compiled for I.P.U.C by, Keshavamurthy.B.T. Dept of C.S. 18


Data representation

Number systems are basically divided into two types. They are,

1. Non-positional number system.


2. Positional number system.

Non-positional number system.-

The non-positional number system consists of different symbols that are used to represent
numbers. Roman number system is the best example for the non-positional number
system.

Positional number system:

Decimal, binary, octal and hexadecimal number systems are some of the examples of this
type of binary [Link] base or radix of a number system is the total number of
digits present in that system.

Decimal number system:

This is the most commonly used number system in our daily life. It has 10
numbers from 0 – 9, hence its radix is 10. The positional values are expressed in powers
of 10.
Ex: 542.76(10)
It can be represented as, 5X102+4X101+2X100+7X10-1+6X10-2
Ex: 654.52 can be represented as ,

Hundreds Tens Units One tenth One


hundredth
Weights 102 101 100 10-1 10-2
Digits 6 5 4 5 2
Weighted value 600 50 4 0.5 .02

Binary number system:

Digital computers cannot process the decimal numbers; hence they require binary number
representation ( 0& 1). The base of binary number system is 2. The positional values are
expressed in terms of power of 2.
Ex: 11011.101(2) can be represented as,

1X24+1x23+0X22+1X21+1X20+1X2-1+0X2-2+1X2-3

Compiled for I.P.U.C by, Keshavamurthy.B.T. Dept of C.S. 19


Weights 24 23 22 21 20 2-1 2-2 2-3
Bits 1 1 0 1 1 1 0 1
Values 16 8 4 2 1 0.5 0.25 0.125

In a binary number the leftmost bit is called as MSB (most significant bit)
Rightmost bit is called as LSB (left significant bit).

Octal number system:

The octal number system has 8 digits, 0,1,2,3,4,5,6,7. Its radix or base is 8. The positional
values are expressed in powers of 8.

Ex: 345(8) can be expressed as, 3X82+4X81+5X80

Ex: 235.21 can be expressed as 2X82+3X81+5X80+2X8-1+1X8-2


Weights 8 n ........ 82 81 80 . 8-1 8-2 8-3 ……. 8-n

Hexadecimal number system:

This number system has 16 digits, 0,1,2,3,4,5,6,7,8,9,A,B,C,D,E and F. The radix is


[Link] position values are expressed in terms of powers of 16. The A,B,C,D,E,F have the
decimal values 10,11,12,13,14 and 15 respectively.

Ex: 5AF.D(16) can be expressed as, 5X162+AX161+FX160+DX16-1

Weight 16n ........ 162 161 160 . 16-1 16-2 16-3 ……. 16-n
s

Ex:DAD(16) can be expressed as, DX162+AX161+DX160

Converting any number system to the decimal number system:

Step1: Determine the positional value of each digit.


Step2: Multiply the obtained value by the digit in the corresponding position.
Step3: Sum the products to get decimal number.

Example1: Convert 111011(2) todecimal,(binary to decimal)

25 24 23 22 21 20 Positional value
1 1 1 0 1 1 111011(2)=
1X25+1X24+1X23+0X
22+1X21+1X20

Compiled for I.P.U.C by, Keshavamurthy.B.T. Dept of C.S. 20


= 32+16+8+0+2+1
= 59(10).

Example2: Convert 10101.101(2) to decimal.(converting binary fraction to decimal)

=1X23+0X22+1X21+0X20+1X2-1+0X2-2+1X2-3
=16+0+4+0+1+0.5+0+0.125
=21.625(10)

Example 3: Convert 1375(8) to decimal.(converting octal to decimal)

1375(8)=1X83+3X82+7X81+5X80
= 512+192+56+5
= 765(10).

Example 4: Convert 735.46(8) to decimal. (converting octal fraction to decimal)

735.46(8)= 7X82+3X81+5X80+4X8-1+6X8-2
= 448+24+5+0.5+0.09375
=477.59375(10)

Example 5: Convert BAD(16) to decimal.(converting hexadecimal to decimal)

BAD(16) =BX162+AX161+DX160
= 11X256+10X16+13X1
=2816+160+13
=2989(10)
Decimal to binary conversion:

1. Divide the given decimal number by 2


2. Note the quotient and remainder
3. Repeat the step1 and step2 until the quotient becomes zero
4. The first remainder will be the LSB and the last remainder is the MSB.

Example: Convert the decimal number 53(10) to binary.

2 53

Compiled for I.P.U.C by, Keshavamurthy.B.T. Dept of C.S. 21


2 26 remainder is 1
2 13 remainder is 0
2 6 remainder is 1
2 3 remainder is 0
2 1 remainder is 1

53(10)=110101(2)

Decimal fraction to binary conversion:

This procedure multiplies the decimal fraction successively by radix 2 and collects all the
numbers to the left of the decimal point (integral part). The reading of the integer part is
from top to bottom.

Example: Convert 0.3125(10) to binary.

integer Fraction

0.3125X2 = 0.6250 0 0.6250


0.6250X2 = 1.2500 1 0.2500
0.2500X2 = 0.5000 0 0.5000
0.5000X2 = 1.0000 1 0.0000

0.3125(10)=0.0101(2)
Decimal to octal conversion:

A decimal fraction can be converted by repeated division method that we used in the
decimal –to-binary conversion. Since the radix of octal numbers is 8 the number is
divided by 8.

Example: 765(10)= ?

8 765
8 95 remainder 5
8 11 remainder 7
8 1 remainder 3

=1375(8).

Decimal fraction to octal:

Example: Convert 0.3125(10) to octal.

0.3125X8=2.5000

Compiled for I.P.U.C by, Keshavamurthy.B.T. Dept of C.S. 22


0.5000X8=4.0000

0.3125(10)=0.24(8).

Decimal to hexadecimal conversion:

A decimal fraction can be converted by repeated division method that we used in the
decimal –to-binary conversion. Since the radix of hexadecimal numbers is 16 the number
is divided by 16.

Example. Convert 559(10) to hexadecimal.

16 559
16 34 remainder 15 this can be written as F
16 2 remainder 2

559(10)=22F(16)

Binary to octal conversion:

The bits of the binary number are grouped into groups of three bits starting at the
[Link] convert each group of bit into its octal equivalent.

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

Convert 1010111(2) to octal.


001 010 111

1 2 7
Adding a leading 0 to MSB of whole number and adding trailing 0 to LSB of fractional
number does not change the value.

Octal to binary conversion:

Convert 456(8) tobinary.

4 5 6

Compiled for I.P.U.C by, Keshavamurthy.B.T. Dept of C.S. 23


Binary equivalent numbers.
100 101 110 = 100 101 110(2).

Binary to hexadecimal conversion:

Convert binary number 1011001(2) to hexadecimal.


 Group these binary bits into group of four bits and write the equivalent
hexadecimal number.

0101 1001 = 59(16)


Hexadecimal to binary conversion:

FACE(16)= ( ? )(2).

F= 1111
A=1010
C=1100
E=1110
FACE(16)= 1111101011001110(2).
Representing signed numbers:

The sign bit is used to indicate the positive or negative nature of the stored binary
number. Remaining bits are magnitude bits that represent the binary equivalent of the
decimal value being represented.

Example: +51 stored in memory using sign and magnitude representation.

0 1 1 0 0 1 1
= + 51

Sign bit magnitude=51(10)

The above picture is the memory where left most bit is the sign bit which stores the sign
and the remaining six bits are the magnitude of the number 110011 which is equal to
decimal value 51.
 If the sign bit is 0 it represents a positive number.
 If the sign bit is 1 it represents a negative number.

1 1 1 0 0 1 1
= -51

Compiled for I.P.U.C by, Keshavamurthy.B.T. Dept of C.S. 24


Sign bit magnitude=51(10)

1’s complement:

The 1’s complement of a number is obtained by the changing each 0 to a 1 and 1 to a


0.

Ex: 1010111 = 0101000

2’s complement:

It is formed by taking the 1’s complement of the number and adding 1 to the least
significant bit position.

Ex: 101000 = 010111 (1’s complement)


Now add 1 to one compliment of the number
010111+1=101000

Decimal Binary Hexadecimal


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

Binary Addition:

Basic rules for addition:

Compiled for I.P.U.C by, Keshavamurthy.B.T. Dept of C.S. 25


Append1 Append2 Sum Carry
0 0 0 0
0 1 1 0
1 0 1 0
1 1 0 1

Example1: Example2: Example3:

100 1001 10101


+11 +1101 10011
111 10110 101000

Binary subtraction:

Basic rules subtraction:

Append1 Append2 Difference Barrow


0 0 0 0
1 0 1 0
1 1 0 0
0 1 1 1

Examples:

101 1110 11011


011 -1001 01001
010 0101 10010

Subtraction with 1’s complement:

1. Determine the 1’s complement of the smaller number


2. Add the 1’s complement to the larger number.
3. Remove the final carry and add it to the result.

Example:Subtract 4 from 9

Minuend (+9) 1001


Subtraend (+4) 0100 ----------1’s complement of subtrahend=1011

1001
1011
10100

Compiled for I.P.U.C by, Keshavamurthy.B.T. Dept of C.S. 26


1 (end-around carry )
0101
The result is 0101=+5.

Example: Subtracting a larger number from the small.( subtract 13 from 9).

Minuend- (+9) 1001


Subtrahend (+13) 1101------------- 1’s complement of subtrahend=0010

1001
0010
No carry 1011 now take 1’s complement of this number and place a negative sign
in front. The result is -0100= -4.

BCD code:

BCD code stands for Binary coded decimal. It is the one of the early computer code.

Example: 537 would be represented in 4-bit BCD code as,

5 3 7
0101 0011 0111

Excess-3BCD Code:

Example: 537 would be represented in Excess 3 BCD code as,

5 3 7
0101 0011 0111
0011 0011 0011…….ADD 3 (0011)
1000 1010 0110->Excess-3 BCD Code

ASCII table :

ASCII is abbreviated as, American Standard Code for Information Interchange.


This code allows manufacturers of various computers to standardize their hardware. It is
used in data communication and to represent data internally in the computer. It is 7 bit
code and it has 27 =128 possible code groups.

Compiled for I.P.U.C by, Keshavamurthy.B.T. Dept of C.S. 27


Chapter 4

SOFTWARECONCEPTS

Introduction
A computer system has three components viz.
Hardware:It consists of the physical components of a computer.

Compiled for I.P.U.C by, Keshavamurthy.B.T. Dept of C.S. 28


Software: A set of instructions that tells the computer to perform an intended task.

Types of Software:
Software is broadly classified into two categories namely,
1. System Software
2. Application Software

System software:
System software is the collection of system programs to perform common tasks.
System software is hardware dependent and not portable. System software provides a
convenient environment for program development and execution.

System software is of three types:


1. Language Translators
2. Operating System
3. Utilities Software

Application Software:
Application software that has been written to process performs a specific job.
Application software is generally written in high level languages. It focus is on the
application, not the computing system.

Operating system:
An operating system is a set of program modules which provides a friendly interface
between the user and the computer resources. It acts as an interface between user and the
hardware.

Language translators.:
The translator translates the high-level language to low level language. There are
three types of translators: Compilers, Interpreters, and Assemblers.

Assembler:
Assembler:
Assembler is system software which translates an assembly language program
into its machine language. It recognizes the mnemonics used in the assembly level
languages and substitutes the required machine code for each instruction.

Compilers:

Compiled for I.P.U.C by, Keshavamurthy.B.T. Dept of C.S. 29


Compiler is system software that translates high-level language (source code) into
the machine level language (machine/object code). It reads the whole program and
translates the entire program at once into a series of machine level language instructions.
Once compiled, the program normally gets saved automatically and can be executed
directly.
Examples: C, C++.

Interpreters:
An Interpreter reads once a statement of a high-level language program at a time
and translates it into machine level language and executes it immediately. It continues to
read, translate and execute the statements one by one until it reaches the end of the
program.
Therefore, it is slower than a compiler.

Linker and Loader:


A source program written in high-level languages may contain a number of
modules or segments. To execute properly the modules are to be linked so that execution
of the program is sequential. This operation is performed by software called as the linker.

A linker is system software that links (combines) smaller programs to form a single
program.
A loader is system software that loads machine code of a program into the system
memory and prepares these programs for execution.

Utility Software:
Utilities are those helpful programs that assist the computer by performing
helpful functions like backing up disk, scanning/cleaning viruses etc. Utility software is
generally called as Application oriented readymade programs. Ex: text editor, notepad,
WordPad etc.

Functions of Operating System(OS):

1. Memory management
2. Processor management

Compiled for I.P.U.C by, Keshavamurthy.B.T. Dept of C.S. 30


3. Device management
4. Information management.

Memory management: it is mainly concerned with the allocation of physical memory


of finite capacity to requesting processors. Important functions of memory management
are,
1. Keeping track of memory status
2. Allocation policy
3. Allocation
4. De-allocation
Process management: It is mainly concerned with assignment of processors to
processes.
Device management: the input and output devices are slow compared to CPU, the OS
has to manage this issue by the concept of synchronization. The activities of device
management task handled by OS are:
1. Open, close and write device drivers.
2. Communication, control and monitor the device drivers.
3. Device allocation and de-allocation.

Information management: it is also called as file management. It is responsible for


managing files in memory. The main functions are,

1. Managing files(create, delete, update, backup and recovery)


2. Providing privileges.
3. Loading information from secondary to primary memory.
4. Secure files

Types of operating system:

Single user operating system:


This OS allows only one user to share the system resource including the CPU.
These are mainly the operating systems configured for the use of desktop PC and laptops.
DOS and Windows- 95, Win-98, Apple Macintosh etc are the examples.

Batch Operating System:


Batch is defined as a group of job with similar needs and similar resource
requirements. The operating system that allows users to create batches and execute each
batch sequentially, processing all jobs of batch considering them as a single process is

Compiled for I.P.U.C by, Keshavamurthy.B.T. Dept of C.S. 31


called “Batch Operating system”. It allows litter or no interaction between users and
executing programs.

This is well suited for applications with large computation time and no user
interaction. Payroll, forecasting, statistical analysis are programs example for its usage.

Multiprogramming Operating System:


Multiprogramming is the capability of CPU to execute two or more programs
concurrently. Two or more programs are stored concurrently in primary storage, and the
CPU moves from one program to another, partially executing each in turn.

Multitasking Operating System:


Multitasking operating systems supports concurrent execution of two or more
processes. It gives you the perception of 2 or more tasks running at the same time. It does
this by dividing system resources for these tasks.
Multitasking is usually implemented by code and data of several programs in
memory simultaneously and multiplexing processor and I/O device among them.
Multitasking is also called context switching.

Multi-user Operating:
A multi-user operating system allows multiple users on different computers or
terminal to access a single system with one OS on it. It creates and maintains individual
user environments, individual authentication and security level privileges, provides per
user resource usage accounting.

Time sharing:
Time-Sharing operating system allows many users to share the computer resource
simultaneously. Time sharing refers to the allocation of computer resource in time slots to
several programs simultaneously. Large CAD and text processing systems belong to
timesharing OS.
Most of the time-sharing operating systems adopted time slicing/ round robin
scheduling algorithm. Each user/process will receive a portion of the time slot.
UNIX, Windows Server is the example for multiprogramming, multi-use and time
sharing systems.

Real-time Operating System:


Real time systems refer to a computer and software systems that respond to events
before the events become obsolete. The primary objective of real-time systems is to
provide quick event – response times and thus meeting the scheduling deadlines.

Distributed Operating System:

Compiled for I.P.U.C by, Keshavamurthy.B.T. Dept of C.S. 32


A distributed operating system is a collection of autonomous computer systems
capable of communication and cooperation via the software and hardware
interconnections. For example: if we have ‘N’ systems in a distributed environment then
the distributed OS helps us in balancing the load by sharing processors, I/O devices and
memory etc.

The ATM centers of a bank are example of distributed operating system.

Network Operating System:


A network operating system is a collection of software and associated protocols
that allow a set of autonomous computer which are interconnected by a computer
network. It can be used in a convenient and cost-effective manner.

Multithreaded Operating System:


A thread is a sequence of instructions within a program. A program or process
may have many threads which share the same code section, data section, and other OS
resources. It provides many logical paths through the program to be executed
simultaneously. Sun Solaris, Windows 2000, Multithreaded UNIX, LINUX are
examples.

Functional Features of Operating System (OS):


There are two types of user interface:

1. Command-Line User Interface (CUI)


2. Graphical User Interface (GUI)

CUI Interface:

CUI interface allows the user to interact with a computer through text terminal.
It is a Non-graphical and text-based user interface.
MS-DOS is an operating system which provides a CUI.
The commands must be given at the command prompt ( C:\>)

GUI Interface:
The GUI was first introduced in 1984 by Apple with Macintosh.
GUI is an interface where the commands are selected from menus and icons rather the
typing them from the keyboard.
It allows user to click on the required icon, with the help of Mouse.
Windows Operating System is the most popular OS based on GUI.

Comparison of CUI and GUI

CUI GUI

Compiled for I.P.U.C by, Keshavamurthy.B.T. Dept of C.S. 33


User has type commands at command Click icon,menu,dialog box to interact
prompt
User must remember commands No need to remember, it available in the
form of icons and menus
Mouse operation not avaialble Mouse required to operate
No multitasking Can be used for multitasking
Command user interface Graphical user interface

Chapter 5.

Problem solving technique

Compiled for I.P.U.C by, Keshavamurthy.B.T. Dept of C.S. 34


Problem solving can be defined as the task expressing the solution to complex problems
in terms of simple operations understood by the computer.

There are seven stages,

1. Problem definition
2. Problem analysis
3. Design of a solution using tools such as flowcharts and algorithms
4. Programming the computer
5. Checking and correcting errors
6. Program documentation
7. Program enhancement or maintenance.

Problem definition

It is the basic stage. The problem should be clearly defined to make the user understand
the problem correctly. It should be in the user language and may include charts, tables
and equations.

Problem analysis

The problem analysis makes the user to understand the requirement of the problem. This
is the first step towards the solution of the problem. This specifies the input and output
requirement of the problem. They are,

What is the type of input data and number of input data?


The type of input device required
Type of output to be generated and its data type.
The output device to be used

Design of a solution using tools such as flowcharts and algorithms

Algorithms and Flowcharts are the two design tools used in designing the problem. Here
the complex problems are divided into sub-problems. This approach is called as the
divide and conquers technique.

Algorithm

It is a step-by-step procedure to solve a given problem. It contains finite number of


operations.

Ex: Algorithm to find area of triangle.


Step1: start

Compiled for I.P.U.C by, Keshavamurthy.B.T. Dept of C.S. 35


Step2: input height and base
Step3: compute area  ½ X base X height
Step4: output area
Step5: stop

Steps in developing the algorithm

Clearly understand the problem


Study the input and type of output to be generated
Design the process
Refine the process
Test the algorithm by giving the test data.

Advantages:

1. Easy to understand
2. Since it has got definite procedure it can execute with the fixed time
3. Easy to convert into flowchart
4. Independent of programming language used
5. Easy for debugging

Disadvantage:

It is time consuming

Characteristics of algorithms:

1. Input: The algorithm must accept one or more input.


2. Definiteness: Each operation step must be clear and there should not be any
ambiguity.
3. Effectiveness: The operation must be simple and are carried out in a finite time at
one or more levels of complexity. It should be effective whenever traced
manually for the results.
4. Output: it should produce at least one output.

Analysis of algorithm:

There may be more than one approach to solve a problem. The choice of a particular
algorithm depends on the following performance analysis and measurements.
1. Space complexity: The amount of memory needed by the algorithm to complete
its run.
2. Time complexity: The amount of time, the algorithm needed to complete its run.

Pseudo code: A narrative description of the flow and logic of the intended program,
written in plain language that expresses each step of the algorithm.

Compiled for I.P.U.C by, Keshavamurthy.B.T. Dept of C.S. 36


Example for algorithm: greatest among three numbers.

Step1: START.

2: (read the three numbers)


INPUT a,b,c
3: Assign a to large.
large=a
4: compare large and y
If(b>large)
large=b
endif
5: if(c>large)
large=c
endif
6: Print the largest number
OUTPUT large.
7: end of algorithm.
STOP.

Flowchart:

It is the pictorial or graphical representation of the algorithm.


It is divided into two types. They are,

1. Program flowcharts: Specifies only the flow of operations of an algorithm pictorially.


But program flowchart never specifies the computer environment in which program will
be executed.

2. System flowcharts: It is flowchart which gives an overall view of computer system


environment in addition to the flow of operations for an algorithm or program to be
solved.

Steps involved in developing flowcharts.

Understand the problem clearly.


Study the output to be generated
Design the process that will give the result.
Refine the process
Test the flowchart giving the test data.

Compiled for I.P.U.C by, Keshavamurthy.B.T. Dept of C.S. 37


Symbols used in flowchart.

Advantages of flowchart.

 Easy to understand
 Easy to convert into a program
 It is independent of program
 Easy for debugging

Disadvantages of flowcharts:

 Time consuming.
 Difficult to represent complex logic.
 Alteration and modifications are difficult because we have to redraw the
flowchart.

Compiled for I.P.U.C by, Keshavamurthy.B.T. Dept of C.S. 38


Coding:
It is the processing of writing the program using the appropriate programming
language. It is the process of converting the flowchart into source code.

Debugging:
It is the process of detecting the errors in a program. The process of debugging
verifies and ensures that the program does what the programmer intended to do.

Program documentation:
The written text and comments that make a program easier for the others to
understand use and modify is called documentation.

Program maintenance:
The process of updating or providing new versions of a program so that the
program meets the present day requirements of the user is called program maintenance.
It is required for following reasons,

1. To detect new errors that was detected during the usage of the program.
2. To make changes according to changing requirements and needs of user.
3. Modifying to provide additional information.

Example to find greatest among three using flow chart:

start

Read a,b,c

Compiled for I.P.U.C by, Keshavamurthy.B.T. Dept of C.S. 39


F T
If a>b

T F F
If T
If b>c
a>c

Print a
Print b Print c

stop

Basic programming construct.

There are three programming constructs.

1. Sequential construct
2. Selection construct
3. Iteration constructs.

Sequence construct.

It is the ability of a programming language to execute the statements one after the other
from beginning to the end.

Selection statements:

If statement

If (expression)
statement;

Compiled for I.P.U.C by, Keshavamurthy.B.T. Dept of C.S. 40


If the condition is true the statement is executed otherwise it is ignored, the control moves
further.

If statement:

A program to find the biggest between the two numbers. (if statement)

#include<conio.h>
#include<iostream.h>
void main()
{
int big, a ,b;
clrscr();
cout<<“enter the two numbers”;
cin>>a>>b;
big=b;
if(a>big)
big=a;
cout<<” biggest among the two numbers=”<<big;
getch();
}

if else statement

Compiled for I.P.U.C by, Keshavamurthy.B.T. Dept of C.S. 41


if (expression)
statement1;
else
statement2;

If the condition is true then the statement1 or statements in the true block gets executed.
If the condition is false then the statement2 or the statements in the false block gets
executed.

Example for if else statement:

A program to find the biggest between the two numbers.

#include<conio.h>
#include<iostream.h>
void main()
{
int big, a ,b;
clrscr();
cout<<“enter the two numbers”;
cin>>a>>b;
if(a>b)
cout<< a is greater”;
else
cout<<“ b is greater”;
getch();
}

Nested if else statement

A if else statement may contain one or more if else statement inside of it, it is known as
nested if else statement.

if(expression1)

if(expression2)

Statement1;
else
Statement2;
else

if(expression3)
statement3;
else
statement4;

Compiled for I.P.U.C by, Keshavamurthy.B.T. Dept of C.S. 42


Example:

if(a>b)
if(a>c)
cout<<“ a is greater”;
else
cout<<“ c is greater”;
else
if(b>c)
cout<<“ b is greater”;
else
cout<<“ c is greater”;

else -if -ladder or if -else -if statement.

It is series of if conditions. If any of the condition gets true then the statements in that
condition block is executed. If none of the condition gets true then the default statement
i.e. the statement after else is executed.

If(condition1)
{
statement1;
}
else if(condition2)
{
statement2;
}
else if(condition3)
{
statement3;
}
else .if(condition..n)
{
statement..n;
}
else
statement;
}
Series of condition are checked for true status. If none of them gets true then default
statement is executed.

Example: A program to grade the students according to their class marks.

#include<conio.h>

Compiled for I.P.U.C by, Keshavamurthy.B.T. Dept of C.S. 43


#include<iostream.h>
void main()
{
int marks;
clrscr();
cout<<“enter the marks of student”;
cin>>marks;
if(marks>=70 && marks<=100)
cout<<“\n distinction”;
else if (marks>=60)
cout<<“\n first class”;
else if (marks>=50)
cout<<“\n second class”;
else if (marks>=35)
cout<<“\n pass class”;
else
cout<<“failed”;
getch();
}

Switch / Case:

The Switch Case structure is similar to a host of if statements. The switch case structure
may have a default condition that is executed if none of the statements match. A
switch/case structure is used when one statement must be chosen from many.

switch ( variable of interest )


{

Compiled for I.P.U.C by, Keshavamurthy.B.T. Dept of C.S. 44


case value1:
code to be executed.
break;
case value2:
code to be executed.
break;
case value3:
code to be executed.
break;
.
.
.
default:
code to be executed.

}
The value in the expression is compared with case labels. If it matches with the
any case label then the statements in that case block gets executed. If none of case labels
matches with the value of expression, then ultimately the default statement will be
executed.

Example program: A program to illustrate switch. (Printing names of colour


according to the code entered)

#include<conio.h>
#include<iostream.h>
void main()
{
char code;
clrscr();
cout<<“ enter the colour code”;
cin>>code;
switch(code)
{
case ‘y’:
cout<<“\n yellow”;
break;
case ‘w’:
cout<<“\n white”;
break;
case ‘b’:
cout<<“\n blue”;
break;
default:
cout<<“\n invalid code entered”;
}

Compiled for I.P.U.C by, Keshavamurthy.B.T. Dept of C.S. 45


getch();
}

Iteration construct:

While Loop:

In a While Loop, the expression is evaluated when the program enters the top of the
loop. If the expression is true, the statements within the loop are executed. As long as the
conditional is evaluated as true, the process repeats. IF the conditional is evaluated as
false, then the code block is skipped.

Syntax:
while (condition)
{
statement block;
}

The while tests its condition at the top of the loop. Therefore, if the condition is false to
begin with, the loop will not execute at all.

Example: A program to print even numbers up to 10.

#include<conio.h>
#include<iostream.h>
void main()
{
int I=2;
clrscr();
while(I<=10)
{
cout<< I<<”\n”;
I=I+2;
}
getch();

Compiled for I.P.U.C by, Keshavamurthy.B.T. Dept of C.S. 46


}

do-while loop/ do-while statement

This is very similar to the while loop except that the test occurs at the end of the loop
body. This guarantees that the loop is executed at least once before continuing. The loop
repeats till the test condition is true. If test condition is false the loop will not repeat.

do
{
statement block;

} while (condition);

Example: A program to print even numbers up to 10.

#include<conio.h>
#include<iostreamo.h>
void main()
{
int I=2;
clrscr();
do
{
cout<<I<<”\n”;
I=I+2;
}
while(I<=10);
getch();
}

Compiled for I.P.U.C by, Keshavamurthy.B.T. Dept of C.S. 47


For Loop:

If the statement block is only one statement, the braces are not necessary. This
statement is normally used when we know how many times the statement is to be
repeated. For statement can be used as increment or decrement loop. The loop repeats set
of statements a specified number of times to the counter value in the condition. When the
condition gets false the repeated execution stops.

for ( variable initialized ; conditional expression ; increment or decrement )


{
perform these statements while the conditional expression is true
}

Example: A program to print even numbers up to n

#include<conio.h>
#include<iostream.h>
void main()
{
intI,n;
clrscr();
cout<<”enter the value for n”;
cin>>n;
for(I=2;I<=n;I=I+2)
cout<<I<<”\n”;
getch();}

Compiled for I.P.U.C by, Keshavamurthy.B.T. Dept of C.S. 48


Ternary condition

The (ternary condition) operator is a more efficient form for expressing simple if
statements. It has the following form:

expression1 ? expression2: expression3

if expression1 is true then expression2 gets executed otherwise expression3 will be


executed.

Example:

big= (a>b) ? a : b;
if a is greater than b then ‘a’ will be assigned to big , if the condition is false then ‘b’ will
be assigned to big.

Characteristics of a good program.

1. Which requires less space in memory than usual?


2. Less executing time.
3. Easy to modify( allows modifications easily)
4. Portable (can be run on different type of machines).

Types of errors that occurs during the execution of program.

Syntax error:- Each programming language have the set of rules and the program
written should follow the rules. Violating the rules makes a syntax error.

Semantic error:-Wrong use of logic in program causes the semantic error.

Logical error:- Even though the correct translation of algorithm causes the program to
produce wrong result then it is said to be having logical error.

Run-time error:-Errors that are detected during the execution of the program is called as
run time error.

Approaches to Problem solving:

Top-down design:-It is viewed as a tree structure. Dividing a problem into a sub


problem and further dividing till becomes easy for solving or to be simple enough to be
easily programmed in the source language.

Stepwise refinement: - The process of breaking down the problem at each stage to
obtain a computer solution is called stepwise refinement.

Compiled for I.P.U.C by, Keshavamurthy.B.T. Dept of C.S. 49


Bottom-up-design: It is reverse of Top-down design. The concept of combining lower
level modules to form higher level modules until the program is realized is called
Bottom-up-design.

Programming techniques:

Unstructured programming: - The main program includes data and statements which
work on that. The main program directly operates on the global data. When the program
becomes too large it is not good to hold this concept.

Procedural programming:- The main contains sub procedures. The main program is
responsible to pass data to the procedures. The data is processed in the procedures and
when program execution is finished the resulting data is presented.

Structured programming:- This method of programming uses the following types of


code structures to write the program,
1. Sequence of sequentially executed statements.
2. Conditional statements.
3. Looping statements.
4. Structured subroutines calls (functions)

Modular programming:-The process of splitting the large programs into smaller units
(modules) is called modularization and programming with such an approach is called
modular programming.

Advantages ,

1. Reusability: The module can be reused according to the requirement of the user
which avoids rewriting of the functions saving the time.
2. Debugging: It is easy to locate the error and correct them since program contains
modules.
3. Building library: It is easy to build the library of commonly used functions by the
user to help reusability.
4. Portability: It is easy run the function on different operating systems without much
or no modifications.

Chapter 6

Compiled for I.P.U.C by, Keshavamurthy.B.T. Dept of C.S. 50


Object Oriented Concepts.

Object Oriented programming

It is a concept that combines both the data and the functions that operate on that
data into a single unit called the object. An object is the instance of class. The functions
of an object called member functions in c++, typically provides the only way to access
the data of that object. The member functions have the right to access the data of its
object. So the data is always hidden and safe from accidental alteration.

Object X Object y

data data

functions functions

Object Z

data

functions

OOPs characteristics:

1 Modularity: It is a technique adopted to divide a complex program into a number of


self contained independent program segments. These segments can be reused in program
according to requirement. Module is self contained independent program.

[Link]: It is an act of which represents the essential features of an entity without


including the explanations or any background details about it. Ex: Even though we know
the use of mobile we don’t know the how the circuit is built and how the OS code is
written. Generally it is process of hiding unwanted details.

3. Data Encapsulation: The wrapping up of data and functions into a single unit called
as class. This concept is known as encapsulation.

Compiled for I.P.U.C by, Keshavamurthy.B.T. Dept of C.S. 51


The concept of insulating the data from the direct access by the program is called data
hiding.

4. Inheritance: The objects of one class acquire the properties of another class is called
inheritance. New class (derived class) can be derived from the old ones (base class).

A Base class

B Derived class(sub class B derived from class A)

[Link]: It is the ability to take more than one form.

The process of making an operator to exhibit different behavior in different instance is


known as operator overloading.
Ex: ‘+ ‘ operator can be made to add two strings even though it is meant for adding
digits.

A function with same name with different parameters can perform different type of tasks
is known as function overloading.

[Link] binding:means that the code associated with a given procedure call is not
known until the time of the call at run time.

[Link] passing: it means the request for execution of a procedure for an object.
Therefore a message invokes a procedure in the receiving object to generate the desired
output.

Benefits of OOP’s.

1. OOP’s model resembles the real world entities very well.


2. Inheritance extends the use of existing classes and eliminates redundant code hence
supports code reusability.
3. Data hiding helps to build secure programs.
4. OOP’s can be easily upgraded.
5. Flexible
6. Multiple instances of objects exist without any inheritance.
7. The programs can be easily tested, managed and maintained.

Applications:

The promising areas for application of OOP are,

1. Real-time systems
2. Simulation and modeling
3. Object oriented databases

Compiled for I.P.U.C by, Keshavamurthy.B.T. Dept of C.S. 52


4. Hypertext, hypermedia and expert text.
5. Artificial intelligence and expert systems
6. CAD, CAM and CIM systems.
7. Decision support systems and Office automation.

Disadvantages:

1. Proper planning and skill is required for programmer before programming in


OOP technique.
2. Needs tricky methods to do programming.

Compiled for I.P.U.C by, Keshavamurthy.B.T. Dept of C.S. 53

You might also like