0% found this document useful (0 votes)
12 views81 pages

Computer Fundamentals and Generations

FUNDAMENTAL

Uploaded by

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

Computer Fundamentals and Generations

FUNDAMENTAL

Uploaded by

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

Unit I

Fundamentals of Computer

P1

Most of the slides are borrowed from Dr. Rakesh Rathi, Asstt. Prof., CSE dept., ECA and few slides from Internet.
Outline
Introduction of Computers
Generation of Computers
Classification and Application of Computers
Basic organization of Computers
Storage Devices
Computer Memory
Levels of Programming Languages
Algorithms and their Representation
Do it Yourself: Home Work

2
A computer is a programmable machine that accepts data as input and performs
computations on those data using programs and gives output.

CHARACTERISTICS OF COMPUTERS
▪Speed : A computer works with much higher speed and accuracy compared to humans while performing mathematical
calculations.
▪Accuracy :Computers perform calculations with 100% accuracy
▪Automatic :Computer performs all the tasks automatically i.e. it performs tasks without manual intervention.
▪Diligence :A computer can perform millions of tasks or calculations with the same consistency and accuracy.
▪Memory : A computer has built-in memory called primary memory where it stores data. Secondary storage are removable devices
such as CDs, pen drives, etc., which are also used to store data.
▪Economical
▪Versatile :Versatility refers to the capability of a computer to perform different kinds of works with same accuracy and efficiency.

3
The word generation means the state of improvement in the product development process. Similarly,
computer generation refers to the different advancements of new computer technology.

First Generation (1940-1956) Vacuum Tubes


▪The first generation computers used very large number of vacuum tubes for circuitry and magnetic

drums for memory.

▪UNIVAC and ENIAC computers are prime examples of first-generation computing devices.

4
Advantages: Fastest calculating device of their time

Disadvantages:

▪Dissipate a lot of heat

▪Consume a lot of electricity

▪Very bulky in size

▪These computers were frequently down due to hardware failures.

▪These computers needed constant maintenance because of low mean time between failures

▪Limited commercial use because these computers were difficult to program

▪Very expensive

5
Second Generation (1956-1963) Transistors

•The second generation computers were manufactured using transistors.

•While first generation computers were programmed using machine language, second generation
computers moved towards symbolic, or assembly languages, which allowed programmers to specify
instructions in words.

•At this time, high-level programming languages like COBOL, FORTRAN, ALGOL and SNOBOL were
also being developed.

•Second generation computers were first to store instructions in memory, which moved from a
magnetic drum to magnetic core technology.

•Second generation computers were first developed for the atomic energy industry.

6
Advantages:

▪Consumed less electricity and thus dissipated less heat as compared to first generation computers

▪Faster, cheaper smaller and more reliable than first generation computers

▪Could be programmed using assembly language and high level languages

▪These computers had faster primary memory and a larger secondary memory

Disadvantages:

▪Second generation computers were manufactured using transistors that had to be assembled

manually. This made commercial production of computers difficult and expensive.

7
Third Generation (1964-1971) Integrated Circuits
• The development of the integrated circuit was the hallmark of the third generation of computers.

• These computers had few megabytes of main memory and magnetic disks which could store few
tens of megabytes of data per disk drive.

• High level programming languages like COBOL and FORTRAN were standardized by ANSI

• Some more high level programming languages like PL/I PASCAL and BASIC were introduced at this
time.

• Third generation computers were the first to implement time sharing operating systems.

• Input to these computers could now be provided using keyboards and mouse.

8
Advantages:
▪Faster than second generation computers and could perform 1 million transactions per second.

▪Smaller, cheaper and more reliable than their predecessors

▪These computers had faster and larger primary memory and secondary storage

▪They were widely used for scientific as well as business applications

▪During this generation of computers, standardization of existing high level languages and invention of

new high level languages was done

▪These computers had time sharing operating system which allowed interactive use of computer by

one or more users simultaneously thereby improving the productivity of the users.
9
Fourth Generation (1971-1989) Microprocessors

•The microprocessor started the fourth generation of computers with thousands of integrated circuits built
onto a single silicon chip.
• Semi-conductor memories were used which were very fast, even the hard disks became cheaper,
smaller in size and larger in capacity.
• For input, floppy disks (in addition to magnetic tapes) were used to port data and programs from one
computer to another.
• During this period many new operating systems were developed like MS-DOS MS-Windows UNIX and
Apple’s proprietary operating system.

•Development of GUIs, the mouse and handheld devices.

•In this period, several word processing packages, spreadsheet packages and graphics packages were
introduced.

10
Advantages:

▪Smaller, cheaper, faster and more reliable

▪Consumed less electricity and therefore dissipated less heat

▪They had faster and larger primary memory and secondary storage

▪They could be used as general purpose computers.

▪GUIs enabled people to learn to work with computers very easily. So the use of computers in both

office and home became widespread.

▪Networks allowed sharing of resources thereby efficient utilization of computer hardware and software

11
Fifth Generation (Present and Beyond) Artificial Intelligence

•The fifth generation computers are completely based on a new concept of artificial intelligence.

•Although such computers are still in development, there are certain applications like voice recognition

which is widely being used today.

•In the fifth generation of computers the aim is to develop devices that respond to natural language

input and are capable of learning and self-organization.

• The two most common are LISP and Prolog.

12
Advantages:

▪Smaller, cheaper, faster and more reliable

▪Consumed less electricity and therefore dissipated less heat

▪They had faster and larger primary memory and secondary storage

▪They could be used as general purpose computers.

▪GUIs enabled people to learn to work with computers very easily. So the use of computers in both

office and home became widespread.

▪Networks allowed sharing of resources thereby efficient utilization of computer hardware and software

13
Supercomputer
Supercomputer is the most expensive and fastest type of computer that performs at or near the currently highest operational rate for computers.

Mainframe
A mainframe computer supports a vast number of users to work simultaneously and remotely.
Apart from providing multi-user facility, it can process large amounts of data at very high speeds and support many input, output and auxiliary
storage devices.

Minicomputers
A minicomputer is powerful enough to be used by multiple users (between 10 to 100) but is smaller in size and memory capacity and cheaper than
mainframes.

Microcomputers
The microcomputer has been intended to meet the personal computing needs of an individual.

Desktop computer
A micro computer sufficient to fit on a desk.

Laptop computer
A portable microcomputer with an integrated screen and keyboard.

Palmtop computer/Digital diary/Notebook/PDAs A hand sized


microcomputer having no keyboard. The screen serves both as an input and output device.

14
• Word Processing • Geology
• Internet • Astronomy
• Digital Audio or Video Composition • Weather Forecasting
• Desktop Publishing • Simulation
• Government • Education
• Traffic Control • Online Banking
• Legal System • Industry and Engineering
• Retail Business • Robots
• Sports • Decision Support Systems
• Travel and Tourism • Expert Systems
• Hospitals
• Business and Industry

15
Five Basic operations of the Computer system:
▪Inputting: The process of entering data and instructions into the computer systems
▪Storing: Saving data and instructions to make them readily available for initial or additional
processing whenever required.
▪Processing: Performing arithmetic operations ( add, subtract, multiply, divide, etc. ) or logical
operations ( comparison like equal to, less than, greater than, etc. ) on data to convert them into
useful information.
▪Outputting: The process of producing useful information or results for the user such as a printed
report or visual display.
▪Controlling: Directing the manner and sequence in which all of the above operations are
performed.

16
17
Input Unit:
▪An input unit of a computer system performs the following functions:
• It accepts (or reads) instructions and data from outside world.
• It converts these instructions and data in Computer acceptable form.
• It supplies the converted instructions and data to the computer system for further processing.

Output Unit:
▪An output unit of a computer system performs the following functions:
• It accepts the results produced by the computer, which are in coded form and hence, cannot be easily
understand by us.
• It converts these coded results to human acceptable (readable) form.
• It supplies the converted result to outside world.

Storage Unit:
▪The storage unit of the computer system performs the following functions:
• Data and instructions required for processing (received for the input device).
• Intermediate results of processing.
• Final results of processing, before they are released to an output device.
18
Primary Storage:
▪Used to hold running program instructions.
▪Used to hold data, intermediate results, and results of ongoing processing of job(s).
▪Fast in operation.
▪Small Capacity.
▪Expensive.
▪Volatile (looses data on power dissipation).
Secondary Storage:
▪Used to hold stored program instructions.
▪Used to hold data and information of stored jobs.
▪Slower than primary storage.
▪Large capacity.
▪Lot cheaper than primary storage.
▪Retains data even without power.

19
Arithmetic Logical Unit (ALU):
▪Arithmetic logical unit of a computer system is the place where the actual executions of
instructions takes place during processing operation.
Control Unit (CU):
▪Control unit of a computer system manages and coordinates the operations of all other
components of the computer system.
Central Processing Unit (CPU):
▪It is the brain of a computer system
▪It is responsible for controlling the operations of all other units of a computer system.

20
Computer System Concept:
▪A computer system has more than one element.
▪All elements of a computer system are logically related.
▪All elements of a computer system are controlled in a manner to achieve the system
goal.

A computer is a system as it comprises of integrated components (input unit, output unit,


storage unit and CPU) that work together to perform the steps called for in the executing
program.

21
Input Devices:
The data and instructions are typed, submitted, Or transmitted to a computer through input
devices. Most common input devices are :
▪Keyboard: Keyboard is like a type-writer. A keyboard, normally, consists of 104 keys. These keys
are classified into different categories are:
Character keys
Function keys
Control keys
Navigation keys
Toggle keys
Miscellaneous keys

▪Mouse: A mouse is the pointing device attached to a computer. It is used to move the cursor
around the screen and to point to an object.
▪Scanner: A scanner is a device that captures pictures or documents so that they can be stored in
storage devices, seen on the video screen, modified suitably, transported to other computers, or
printed on a printer.
22
Output Devices:
▪Output devices mirror the input data, or show the output results of the operations
on the input data or print the data.
The most common output device is monitor or visual display unit.
The printer is used to print the result. A hard copy refers to a printout showing the information.
On the other hand soft copy means information stored on a storage device.
▪Monitor:
◦ Computer display devices are commonly known as Visual Display Unit (VDU) or monitor.
◦ Various technologies have been used for computer monitors. CRT (Cathode-ray tube) and
LCD (liquid crystal display) monitors are the two common types which are widely used.
▪Printer:
◦ The printer is a device that prints any data, report, document, picture, diagrams, etc. Printers
are categorized based on the physical contact of the print head with the paper to produce a
text or an image.

23
▪ The memory unit is composed of an ordered sequence of storage cells, each capable of storing one byte of
data.
◦ Each memory cell has a distinct address which is used to refer while storing data into it or retrieving data
from it.
▪ Both RAM and cache memory are referred to as primary memory.
◦ Primary memory is comparatively expensive, and loses all its data when the power is turned off.
◦ Secondary memory provides less expensive storage that is used to store data and instructions on a
permanent basis.
▪ The various types of memory used in a computer system differ in speed, cost, size, and volatility
(permanence of storage). They can be organized in a hierarchy.

24
25
PROCESSOR REGISTERS:

▪Processor registers are located inside the processor and are therefore directly accessed by the CPU. Each register stores

a word of data (which is either 32 or 64 bits). CPU instructions instruct the arithmetic and logic unit to perform various
calculations or other operations on this data. Registers are the fastest of all forms of computer data storage.

CACHE MEMORY:

▪Cache memory is an intermediate form of storage between ultra-fast registers and the RAM. The CPU uses cache memory

to store instructions and data that are repeatedly required to execute programs thereby improving the overall system speed
and increase the performance of the computer.

▪Cache memory is basically a portion of memory made of high-speed static RAM (SRAM) instead of the slower and

cheaper dynamic RAM (DRAM) which is used for main memory.

26
TYPES OF RAMS:

▪SRAM (Static RAM) and DRAM (Dynamic RAM): This is a type of RAM that holds data without an external refresh as long

as it is powered. This is in striking contrast with the DRAM which must be refreshed multiple times in a second to hold its
data contents.

▪SRAM is made of D flip flops in which the memory cells flip-flop between 0 and 1 without the use of capacitors. Therefore,

there is need for an external refresh process to be carried out.

▪SRAM occupies more space and is expensive as compared to DRAM. While each transistor on a DRAM chip can store

one bit of information, the SRAM chip, on the other hand requires four to six transistors to store a bit.

▪However, SRAM is faster and more reliable than DRAM. SRAM is often used as cache memory. Static RAM chips are also

used in cars, household appliances and handheld electronic devices.

27
READ ONLY MEMORY (ROM):
▪ROM refers to computer memory chips containing permanent or semi-permanent data. Unlike RAM, ROM is non-volatile.
▪Most computers contain a small amount of ROM that stores critical programs such as BIOS which is used to boot the
computer when it is turned on.
▪Rewritable ROM chips include PROMs, EPROMs and EEPROMs.

▪ Programmable read-only memory (PROM) can be written to or programmed using a special device called a PROM

programmer. The PROM programmer uses high voltages to permanently destroy or create internal links within the chip. The
working of a PROM is similar to that of CD-ROM recorder which enables the users to "burn" programs onto blanks once.

▪Erasable programmable read-only memory (EPROM) can be erased and re-programmed by exposing the chip to strong

ultraviolet light for 10 minutes or longer and then rewritten with a process that again needs higher than usual voltage
applied. The EPROM is much more useful than PROM and can be compared with a reusable CD-RW.

28
Electrically erasable programmable read-only memory (EEPROM) is based on a similar semiconductor structure to
EPROM, but allows its entire or selected contents to be electrically erased, then rewritten electrically, so that they need not
be removed from the computer (or camera, MP3 player, etc.). The process of writing an EEPROM is also known as
flashing.

Flash memory is also a type of EEPROM in which the contents can be erased under software control. This is the most
flexible type of ROM, and is widely used to store BIOS programs. It is primarily used in memory cards, USB flash drives,
MP3 players, PDAs (personal digital assistants), laptop computers, digital audio players, digital cameras, and mobile
phones. The EEPROM blurs the difference between what "read-only" really means. However, the EEPROM is rewritten only
once a year or so, compared to real read-write memory (RAM) where rewriting is done often many times per second.

29
HARD DISK:
▪A hard disk is a set of disks stacked together like phonograph records, that has data recorded electromagnetically in
concentric circles also known as tracks.
▪A single hard disk includes several platters (or disks) that are covered with a magnetic recording medium.

▪Each platter requires two read/write heads, one for each side.

▪Data is actually stored on the surface of a platter in sectors and tracks. While tracks are concentric circles, sectors on the
other hand are pie-shaped wedges on a track.
▪A track is divided into a number of segments (also called sectors) that can store a fixed number of bytes- for example, 256
or 512.
▪The performance of a hard disk depends on its access time where access time is the time required to read or write on the
disk. Access time is actually a combination of three components:
• Seek time

• Rotational delay

• Transfer time

30
Seek time: The time taken to position the R/W head over the appropriate cylinder (usually around 8 msec on average).
Seek time varies depending on the position of the access arm when the R/W command is received. Seek time will be
maximum when the access arm is positioned over the innermost track while the data that has to be accessed is stored on
the outermost track. Similarly, seek time will be zero if the access arm is already positioned over the desired track. On an
average, the seek time varies from 10-100 milliseconds.
Rotational delay: The time taken to bring the target sector to rotate under the R/W head. Assuming that the hard disk has
7,200 rotations per minute, or 120 rotations per second, a single rotation is done in approximately 8 msec. The average
rotational delay is around 4 msec.
Transfer time: The time to transfer data or the time taken to read/write to a disk is called transfer rate.
The overall time required to access data = seek time + rotational delay + transfer time.
To access data from the hard disk, a disk address has to be specified. The disk address consist of Sector number, Track
number and Surface number (when data is recorded on both the sides of the disk)
Storage capacity of a disk with multiple recording surfaces can be calculated as:
• Storage capacity = no. of recording surfaces * no. of tracks per surface * no. of sectors per track * no. of bytes per sector

31
OPTICAL DRIVE:
▪Optical storage refers to storing data on an optically readable medium by making marks in a pattern that can be read using
a beam of laser light precisely focused on a spinning disc.
▪An optical storage media consists of a flat, round, portable metal disc, which is usually 0.75 inches in diameter and less
than one-twentieth of an inch thick.
▪The disc is coated with a thin metal or plastic or other material that is highly reflective.

▪The optical disk stores information in the form of pits and lands. The pits are the tiny reflective bumps created with laser
beam and lands are flat areas separating the pits. While a land reflects the laser light and is read as binary digit 1, a pit on
the other hand absorbs the light and is read as binary digit 0.
▪Like magnetic disk, the optical disk also has tracks which are divided into sectors but shape of these sectors is different
than that of magnetic disk.

32
Advantages:

• Enable random access of data

• Can be often used as a shared device in a multi-user environment

• Preferred both for online and offline storage of data

• Can store large amounts of data

• The cost of data storage is very low.

Disadvantages:

• Must be stored in a dust free environment

• Magnetic disks are larger in size and heavy in weight

33
OPTICAL DRIVE:
▪Optical storage refers to storing data on an optically readable medium by making marks in a pattern that can be read using
a beam of laser light precisely focused on a spinning disc.
▪An optical storage media consists of a flat, round, portable metal disc, which is usually 0.75 inches in diameter and less
than one-twentieth of an inch thick.
▪The disc is coated with a thin metal or plastic or other material that is highly reflective.

▪The optical disk stores information in the form of pits and lands. The pits are the tiny reflective bumps created with laser
beam and lands are flat areas separating the pits. While a land reflects the laser light and is read as binary digit 1, a pit on
the other hand absorbs the light and is read as binary digit 0.
▪Like magnetic disk, the optical disk also has tracks which are divided into sectors but shape of these sectors is different
than that of magnetic disk.

34
Compact Disc Read-Only-Memory (CD-ROM):

▪It is a type of optical disc that uses laser technology to read and write data on the disc. The information stored on CDROM

becomes permanent and cannot be altered. This means that the stored information can only be read for processing.

▪Digital Video Disk or Digital Versatile Disc (DVD-ROM):

▪It is an extremely high capacity optical disc with storage capacity from 4.7 GB to 17 GB. DVDs are widely used to store
large databases, movies, music, complex software etc.
▪Most of the DVD-ROMs are double sided discs as they can store data on both the sides of the disc.

▪DVDROMs have a multi-layer storage technique and smaller sized pits and tracks. When data is recorded on a DVD, the
laser starts on the inside of the disk and moves outward. The laser beam has a smaller wavelength and can be focused on
two different layers on the disk.

▪Compact Disc Rewritable (CD-RW): is an erasable optical disk. The user can write and over-write data on the CD-RW disc

multiple times.

35
USB FLASH DRIVES:

▪USB flash drives are removable, rewritable, and physically much smaller drives weighing even less than 30 g.

▪A flash drive consists of a small printed circuit board carrying the circuit elements and a USB connector, insulated

electrically and protected inside a plastic, metal, or rubberized case which can be carried in a pocket or on a key chain.

Advantages:
• Data stored on flash drives is impervious to scratches and dust
• Mechanically very robust
• Easily portable
• Have higher data capacity than any other removable media.
• Compared to hard drives, flash drives use little power
• Flash drives are small and light-weight devices
• Flash drives can be used without installing device drivers.

36
Disadvantages:

•Can sustain only a limited number of write and erase cycles before the drive fails.

•Most flash drives do not have a write-protect mechanism

•Flash drives are very small devices that can easily be misplaced, left behind, or otherwise lost.

•The cost per unit of storage in a flash drive is higher than that of hard disks

Uses of flash drives:

• Personal data transport

• System administration

• Booting operating systems

• Music storage and marketing

• Brand and product promotion

• Backup

37
USB FLASH DRIVES:

▪USB flash drives are removable, rewritable, and physically much smaller drives weighing even less than 30 g.

▪A flash drive consists of a small printed circuit board carrying the circuit elements and a USB connector, insulated

electrically and protected inside a plastic, metal, or rubberized case which can be carried in a pocket or on a key chain.

Advantages:
• Data stored on flash drives is impervious to scratches and dust
• Mechanically very robust
• Easily portable
• Have higher data capacity than any other removable media.
• Compared to hard drives, flash drives use little power
• Flash drives are small and light-weight devices
• Flash drives can be used without installing device drivers.

38
FLOPPY DISK:

▪Floppy disks are data storage devices that consist of a thin magnetic storage medium encased in a square plastic shell
lined with fabric.
▪The mechanism of a floppy disk has two motors. One motor in the drive rotates the diskette at a regulated speed, the
second motor moves the magnetic RW head,
▪along the surface of the disk. To read/write data on the disk media, there must be a physical contact between the read–
write head and the disk media.

Reading/Writing data on the disk

▪To write data on the floppy disk, current is passed through a coil in the head. The magnetic field of the coil magnetizes
spots on the disk as it rotates. The change in magnetization encodes the digital data.
▪Similarly, to read data from the floppy disk, a small amount of current is induced in the head coil to detect the
magnetization on the disk. The floppy drive controller separates the data from the stream of pulses coming from the floppy
drive, decodes the data, tests for errors, and sends the data on to the host computer system.

39
MAGNETIC TAPE:
▪Magnetic tape is a thin strip of plastic coated with magnetic recording material. These storage devices are used as
sequential access secondary storage device.
Storage capacity of magnetic tape = data recording density * length of the tape

▪Data is recorded in the form of tiny non-magnetized and magnetized spots, where the presence of a spot represents 1 and
its absence represents 0. This means that data is stored in the form of zeroes and ones.

Advantages of Magnetic Tape:


▪Compact in size, light in weight and can store large amounts of data.
▪Easily portable
▪Economical
▪Consume less power
▪Can be used for long term data storage and retrieval

Disadvantages of Magnetic Tape:


▪Data stored on the tape can be accessed only sequentially
▪Data on a tape is accessed at a very slow speed
▪A special hw is required to read the data stored on tapes
▪Susceptible to degradation due to heat, humidity, dust, mishandling, electromagnetic surfaces and ordinary wear

40
FLOPPY DISK:

▪Floppy disks are data storage devices that consist of a thin magnetic storage medium encased in a square plastic shell
lined with fabric.
▪The mechanism of a floppy disk has two motors. One motor in the drive rotates the diskette at a regulated speed, the
second motor moves the magnetic RW head,
▪along the surface of the disk. To read/write data on the disk media, there must be a physical contact between the read–
write head and the disk media.

Reading/Writing data on the disk

▪To write data on the floppy disk, current is passed through a coil in the head. The magnetic field of the coil magnetizes
spots on the disk as it rotates. The change in magnetization encodes the digital data.
▪Similarly, to read data from the floppy disk, a small amount of current is induced in the head coil to detect the
magnetization on the disk. The floppy drive controller separates the data from the stream of pulses coming from the floppy
drive, decodes the data, tests for errors, and sends the data on to the host computer system.

41
MEMORY CARD:

▪A small device that can store a wide range of files. They are easily portable from one place to another

▪It implements flash memory to add/delete files multiple times.

▪Most of these cards have constantly powered nonvolatile memory

▪Memory cards have no moving parts therefore they are unlikely to suffer from mechanical difficulties.

▪Since newer memory cards are smaller, require less power, have higher storage capacity, are completely silent, less prone

to mechanical failures, allow immediate access to data and are portable among a greater number of devices, they are being
widely used in the production of an increasing number of small, lightweight and low-power devices.

▪Although memory cards are far better than hard disks, they still could not replace them because a memory card is quite

expensive.

42
MEMORY CARD:

▪A small device that can store a wide range of files. They are easily portable from one place to another

▪It implements flash memory to add/delete files multiple times.

▪Most of these cards have constantly powered nonvolatile memory

▪Memory cards have no moving parts therefore they are unlikely to suffer from mechanical difficulties.

▪Since newer memory cards are smaller, require less power, have higher storage capacity, are completely silent, less prone

to mechanical failures, allow immediate access to data and are portable among a greater number of devices, they are being
widely used in the production of an increasing number of small, lightweight and low-power devices.

▪Although memory cards are far better than hard disks, they still could not replace them because a memory card is quite

expensive.

43
Motherboard:

▪All the components in the


computer system are mounted
and connected together by an
electronic circuit board called
motherboard or main board.
▪A motherboard consists of the
following :
CPU socket
Memory sockets
Interface module
ROM integrated chip
Ports and expansion slots

44
Computer System
⚫ Computer System

Hardware + Software
Software
DIFFERENT CATEGORIES OF SOFTWARE:
System software: operate computer hardware and provide and maintain
a platform for running application software, e.g. Device drivers,
Operating system, compiler, debugger, etc.

Application software: is designed for users to solve a particular problem,


e.g. payroll, web browers, Wordprocessor, spreadsheet (excel),
graphics SW, artificial intelligence SW, Game SW, Statistics SW,
medical SW, etc.
Software
Compiler: A computer program that transforms source code (written in a programming language)
into machine language (called object code).
Interpreter: A computer program that directly executes instructions written in a programming
language, without requiring them previously to have been compiled into a machine language
program.
Linker: It takes one or more object files or libraries as input and combines them to produce a single
(usually executable) file.
Loader: A computer program that copies programs from a storage device to the main memory
where they can be executed.
Assembler: It is a program that translates an assembly language program into machine code.

Syntax: The syntax of a programming language is the set of rules that defines the combinations of
symbols that are considered to be correctly structured statements or expressions in that language.
(spelling and grammer rules in natural language).
▪Semantic: It is the meaning of those expressions, statements.
Bug: It is a programming error.
Debugging: It is the process of eliminating errors from a program. 47
Programming Languages:
▪A programming language can be defined formally as an artificial formalism in which algorithms can be expressed.
▪ It is composed of a set of instructions in a language understandable to the programmer and recognizable by a
computer.
▪ Computer languages have been continuing to grow and evolve since the 1940’s.
▪ Assembly language was the normal choice for writing system software like operating systems, etc. But, C has been
used to develop system software since its emergence.
▪ COBOL is more suitable for business applications whereas FORTRAN is more suitable for scientific applications.

Generations of Programming Languages:


▪Just as hardware is classified into generations based on technology, computer languages also have a generation
classification based on the level of interaction with the machine.
▪Generation of Programming Languages :
▪ First generation language (1GL)—machine language
▪ Second generation language (2GL)—assembly language
▪ Third generation language (3GL)—high-level language
▪ Fourth generation languages (4GL)
▪ Fifth generation language (5GL)

48
First generation language (1GL) — Machine Language:
▪The instructions in machine language are written in the form of binary codes that can immediately be
executed by the processor.
▪ The first part is the operation code that conveys to the computer what function has to be performed by the instruction.
▪ All computers have operation codes for functions such as adding, subtracting and moving.
▪ The second part “Mode” specifies the type of addressing used by the instruction to obtain the operand referred by the
instruction.
▪ The third part of the instruction either specifies that the operand contains data on which the operation has to be
performed.
▪ A machine language instruction generally has three parts as shown in Fig.

49
Difficult to use and Error Prone:
▪It is difficult to understand and develop a program using machine language.
▪ Because it is hard to understand and remember the various combinations of 1’s and 0’s representing data and
instructions.
▪ The programmer has to remember machine characteristics while preparing a program.
▪ Checking machine instructions to locate errors are about as tedious as writing the instructions.
▪ Nevertheless, computer hardware recognizes only this type of instruction code.

Machine dependent:
As the internal design of the computer is different across types, which in turn is determined by the actual design or
construction of the ALU, CU, and size of the word of the memory unit, the machine language also varies from one type of
computer to another.

50
Second generation language (2GL) — Assembly language:
▪Assembly language is considered to be a second generation language (2GL).
▪ In this language, an instruction is expressed using mnemonic codes instead of binary codes.
▪ Labels are used to identify and reference instructions in the program.
▪ The operation code is a symbolic notation that specifies the particular operation to be performed, such as MOV, ADD,
SUB, or CMP etc.
▪ The operand represents the register or the location in main memory where the data to be processed is located.
▪ An assembler is a translator that produces machine language code from an assembly language code.
▪ The most eminent disadvantage of assembly language is that it is machine dependent.

51
Third generation language (3GL) — High Level Language:
▪High-level languages are called third generation languages (3GLs).
▪High-level programming languages were developed to make programming easier and less error-prone.
▪Languages like C, C++, COBOL, FORTRAN, BASIC, PASCAL etc., have instructions that are similar to English language
that makes it easy for a programmer to write programs and identify and correct errors in them.
Advantages of High Level Languages:
▪Readability: Programs written in these languages are more readable than those written in assembly and machine
languages.
▪Portability:
▪ High-level programming languages can be run on different machines with little or no change.
▪ It is, therefore, possible to exchange software, leading to creation of program libraries.

▪Easy debugging: Errors can be easily detected and removed.


▪Ease in the development of software:
▪ Since the instructions or statements of these programming languages are closer to the English language, software can
be developed with ease.
▪ The time and cost of creating machine and assembly language programs were quite high.
▪ This motivated the development of high-level languages.

52
Fourth generation language (4GL):
▪The Fourth Generation Language (4GL) is a non-procedural language that allows the user to simply specify
what is wanted without describing the steps that the computer has to follow to produce the result.
▪ This class of languages requires significantly fewer instructions to accomplish a particular task than does a third
generation language.
▪ A query language is used as a database user interface and hides the specific details of the database from the user.
▪ Like third generation languages, fourth generation languages are mostly machine independent. They are primarily used
mainly for developing business applications.
▪ Most of the fourth generation languages can be easily learnt and employed by end-users.

Fifth generation language (5GL):


▪Natural languages represent the next step in the development of programming languages belonging to Fifth
Generation Language (5GL).
▪ Natural language is similar to query language, with one difference: it eliminates the need for the user or programmer to
learn a specific vocabulary, grammar, or syntax.
▪ Actually, 5GL is a programming language based around solving problems using constraints given to the program,
rather than using an algorithm written by a programmer.
▪ Fifth generation languages are used mainly in artificial intelligence research.
▪ OPSS and Mercury are examples of fifth generation languages.

53
Classification of Programming Languages:

54
Compilation Process:
▪Conceptually, the compilation process can be divided into a number of phases
▪ In the first phase of compilation, termed as lexical analysis, each statement of a program is analysed and broken into
individual lexical units termed tokens and constructs a symbol table for each identifier.
▪ The second stage of translation is called syntax analysis; tokens are combined into syntactic units according to the
syntax or grammar of the source language.
▪ In the third stage of compilation, the parsed statements are analysed further to make sure that the operators and
operands do not violate source language specifications.
▪ Next, an intermediate representation of the final machine language code is produced. Optionally, the intermediate code
is optimized to produce an optimized code.
▪ The last phase of translation is code generation whereby the optimized intermediate code is converted into target code.

55
Translators:
▪ A high-level source program must be translated first into a form the machine can execute. This is done by the system software
called the translator.
▪ There are three types of translators, namely Assembler, Compiler and Interpreter. Assembler converts one assembly language
statement into a single machine language instruction.
▪ Depending on its implementation, a high-level language employs a compiler or an interpreter or both for translation.
▪ One statement in a high-level programming language will be translated into several machine language instructions.
▪ Both compiler and interpreter translate a program written in high-level language into machine language but in different fashion.
▪ Compiler translates the entire source program into object program at once and then the object files are linked to produce a
single executable file.
▪ A high-level source program must be translated first into a form the machine can execute. This is done by the system software
called the translator.

Linker:
▪The machine language program produced by the translator must normally be combined with other machine
language programs residing within the library to form a useful execution unit.
▪ Linking resolves the symbolic references between object programs. It makes object programs known to each other. The
system software responsible for this function is known as linker.
▪ This process of program combination is called linking and the software that performs this operation is variously known as a
linker.
▪ The features of a programming language influence the linking requirements of a program.
▪ In languages like FORTRAN, COBOL, C, all program units are translated separately. Hence, all subprogram calls and
common variable references require linking. 56
Loader:
▪Loading is the process of bringing a program from secondary memory into main memory so it can run.
▪ The system software responsible for it is known as loader.
▪ The simplest type of loader is absolute loader which places the program into memory at the location prescribed
by the assembler.
▪ Bootstrap loader is an absolute loader which is executed when computer is switched on or restarted to load the
operating system.
▪ In most of the cases, when a compiler translates a source code program into object code, it has no idea where
the code will be placed in main memory at the time of its execution.

57
Algorithms:
▪To solve any problem a plan is needed. This plan is a procedure to solve the problem in question.
▪The procedure has to be based on definite reasoning and logic to obtain a result.
▪A well-designed algorithm will always provide an answer; it may not be the desired answer but there will be an answer.
▪A well-designed algorithm is also guaranteed to terminate.

What is an Algorithm?
▪Computer scientist Niklaus Wirth stated that:
Program = Algorithms + Data
▪An algorithm is a part of the plan for the computer program. In fact, an algorithm is ‘an effective procedure for solving a
problem in a finite number of steps’.
▪It is effective, which means that an answer is found and it has a finite number of steps.

Different ways of Stating Algorithms:


▪Algorithms may be represented in various ways. The four common ways of representing an algorithm are as follows:
▪ Step-form
▪ Pseudo-code
▪ Flowchart
▪ Nassi-Schneiderman

58
Key Features – Algorithms and step form:
▪Here is an example of an algorithm, for making a pot of tea.
§ If the kettle does not contain water, then fill the kettle.
§ Plug the kettle into the power point and switch it on.
§ If the teapot is not empty, then empty the teapot.
§ Place tea leaves in the teapot.
§ If the water in the kettle is not boiling, then go to step 5.
§ Switch off the kettle.
§ Pour water from the kettle into the teapot.
[Link] this example, it is evident that algorithms show these three features:
1. Sequence (also known as process)
2. Decision (also known as selection)
3. Repetition (also known as iteration or looping)

59
Sequence:
▪Sequence means that each step or process in the algorithm is executed in the specified order. In the above example, each
process must be in the proper place otherwise the algorithm will fail.
▪The decision constructs—if ... then, if ... then ... else...
if proposition
then process1
else process2
▪This is the if … then … else … form of the decision. This means that if the proposition is true then execute process1, else, or
otherwise, execute process2.
Repetition Constructs – repeat & While:
▪Repetition can be implemented using constructs like the repeat loop, while loop, and if.. then .. goto .. Loop.
▪ The Repeat loop is used to iterate or repeat a process or sequence of processes until some condition becomes true.
Repeat
Process1
Process2
..........
………..
ProcessN
Until proposition
60
Correctness:
▪The prepared algorithm needs to be verified for its correctness.
▪ Correctness means how easily its logic can be argued to satisfy the algorithm’s primary goal.
▪ Correctness is the degree to which an algorithm performs its specified function.
▪ The most common measure of correctness is defects per Kilo Lines of Code (KLOC) that implements the algorithm,
where defect is defined as the verified lack of conformance to requirements.
▪This requires the algorithm to be made in such a way that all the elements in it are traceable to the requirements.

Variables and Data Types:


▪The data used in algorithms can be of different types. The simplest types of data that an algorithm might use are
▪ numeric data, e.g., 12, 11.45, 901, etc.
▪ alphabetic or character data such as ‘A’, ‘Z’, or ‘This is alphabetic’.
▪ logical data, that is, propositions with true/false values.

▪Naming of variables
▪ One should always try to choose meaningful names for variables in algorithms to improve the readability of the algorithm
or program. This is particularly important in large and complex programs.
▪Data is a symbolic representation of value.

▪A variable, which has a name, is a container for a value that may vary during the execution of the program.

61
An Example:

62
Program Structure:
Subroutines:
▪A subroutine is a logical collection of
instructions that is invoked from within
a larger program to perform a specific
task.
▪The subroutine is relatively
independent of the remaining
statements of the program that
invokes it.
▪A subroutine can be invoked several
times from several places during a
single execution of the invoking
program.
▪ After completing the specific task, a
subroutine returns to the point of
invocation in the larger program.

63
Examples – Developing algorithms using Step-Form:
▪For illustrating the step-form the following conventions are assumed:
1. Each algorithm will be logically enclosed by two statements START and STOP.
2. To accept data from user, the INPUT or READ statements are to be used.
3. To display any user message or the content in a variable, PRINT statement will be used. Note that the message will be
enclosed within quotes.
4. There are several steps in an algorithm. Each step results in an action. The steps are to be acted upon sequentially in
the order they are arranged or directed.
5. The arithmetic operators that will be used in the expressions are
i. ‘←’ ….Assignment (the left-hand side of ‘←’ should always be a single variable)
ii. ‘+’….. Addition
iii. ‘–’….. Subtraction
iv. ‘*’….. Multiplication
v. ‘/’….. Division
6. In propositions, the commonly used relational operators will include
i. ‘>’ ….. Greater than
ii. ‘<=’ …..Less than or equal to
iii. ‘<’ …… Less than
• ‘=’ …… Equality
• ‘>=’ …… Greater than or equal to
1. ‘!=’ …… Non- equality

64
Examples – Developing algorithms using Step-Form:
▪The most commonly used logical operators will be AND, OR and NOT. These operators are used to specify multiple test
conditions forming composite proposition. These are
i. ‘AND’…… Conjunction
ii. ‘OR’ …… Disjunction
iii. ‘NOT’ …… Negation

Pseudo - code:
▪Like step-form, Pseudo-code is a written statement of an algorithm using a restricted and well-defined vocabulary.
▪ It is similar to a 3GL, and for many programmers and program designers it is the preferred way to state algorithms and
program specifications.
▪Although there is no standard for pseudo-code, it is generally quite easy to read and use.
▪ For instance, a sample pseudo- code is written as follows:
dowhile kettle_empty
Add_Water_To_Kettle
end dowhile

65
Flowcharts:
▪A flowchart depicts appropriate steps to be followed in order to arrive at the solution to a problem.
▪It is a program design tool which is used before writing the actual program.

Guidelines for drawing a flowchart:


▪Flowcharts are usually drawn using standard symbols; however, some special symbols can also be developed when required.

Flowcharts Symbols:

66
Standards for Flowcharts:
▪The following standards should be adhered to while drawing flow charts.
▪ Flowcharts must be drawn on white, unlined 8½¢¢ × 11¢¢ paper, on one side only.
▪ Flowcharts start on the top of the page and flow down and to the right.
▪ Only standard flowcharting symbols should be used.
▪ A template to draw the final version of flowchart should be used.
▪ The contents of each symbol should be printed legibly.
▪ English should be used in flowcharts, not programming language.
▪ The flowchart for each subroutine, if any, must appear on a separate page. Each subroutine begins with a terminal
symbol with the subroutine name and a terminal symbol labelled return at the end.
▪ Draw arrows between symbols with a straight edge and use arrowheads to indicate the direction of the logic flow.

67
Advantages of using Flowcharts:
▪Communication: Flowcharts are a better way of communicating the logic of a system to all concerned.

▪Effective analysis: With the help of flowcharts, problems can be analysed more effectively.

▪Proper documentation: Program flowcharts serve as a good program documentation needed for various purposes.

▪Efficient coding: Flowcharts act as a guide or blueprint during the systems analysis and program development phase.

▪Proper debugging: Flowcharts help in the debugging process.

▪Efficient program maintenance: The maintenance of an operating program becomes easy with the help of a flowchart.

Limitations of Using Flowcharts:


▪Complex logic: Sometimes, the program logic is quite complicated. In such a case, a flowchart becomes complex and clumsy.

▪Alterations and modifications : If alterations are required, the flowchart may need to be redrawn completely.

▪Reproduction : Since the flowchart symbols cannot be typed in, the reproduction of a flowchart becomes a problem.

▪Loss of objective: The essentials of what has to be done can easily be lost in the technical details of how it is to be done.

68
Strategy – Designing Algorithms:
▪Investigation step
1. Identify the outputs needed.
2. Identify the input variables available.
3. Identify the major decisions and conditions.
4. Identify the processes required to transform inputs into required outputs.
5. Identify the environment available.
▪Top–down development step
1. Devise the overall problem solution by identifying the major components of the system.
2. Verify the feasibility of breaking up the overall problem solution.

[Link] refinement
§ Work out each and every detail for each small piece of manageable solution procedure.
§ Decompose any solution procedure into further smaller pieces and iterate until the desired level of detail is achieved.
§ Group processes together which have some commonality.
§ Group variables together which have some appropriate commonality.
§ Test each small procedure for its detail and correctness and its interfacing with the other small procedures.

69
Tracing an Algorithm to Depict Logic:
▪An algorithm is a collection of some procedural steps that have some precedence relation between them.
▪Certain procedures may have to be performed before some others are performed.
▪Hence, an algorithm is a collection of procedures that results in providing a solution to a problem.
▪Tracing an algorithm primarily involves tracking the outcome of every procedure in the order they are placed.
▪Tracking in turn means verifying every procedure one by one to determine and confirm the corresponding result that is to be
obtained.
Convert Algorithms into Program:
▪Once the algorithm, for solution of a problem, is formed and represented using any of the tools like step-form or flowchart or
pseudo code, etc., it has to be transformed into some programming language code.
▪ This means that a program, in a programming language, has to be written to represent the algorithm that provides a solution to a
problem.

▪The general procedure to convert an algorithm into a program is given as follows:


▪ Code the algorithm into a program
▪ Desk-check the program
▪ Evaluate and modify, if necessary, the program
▪ Do not reinvent the wheel

70
Convert Pseudo Code to C Program:

71
Structured Programming Concept:
▪Structured programming is:
▪ Concerned with improving the programming process through better organization of programs and better programming notation to facilitate
correct and clear description of data and control structure.
▪ Concerned with improved programming languages and organized programming techniques which should be understandable and therefore,
more easily modifiable and suitable for documentation.
▪ More economical to run because good organization and notation make it easier for an optimizing compiler to understand the program logic.
▪ More correct and therefore more easily debugged, because general correctness theorems dealing with structures can be applied to prove
the correctness of programs.
▪ In 1968, computer scientist Edsger Dijkstra of Netherlands published a letter to the editor in the journal of the Association of Computing
Machinery with the title ‘Go To statement considered harmful’.
▪ For three decades, Dijkstra had been crusading for a better way of programming—a systematic way to organize programs—called
structured programming.

Structured programming can be defined as a:


▪ top–down analysis for program solving
▪ modularization for program structure and organization
▪ structured code for individual modules

72
Top Down Analysis:
▪Top-down analysis is a method of problem solving and problem analysis.
▪ The essential idea is to subdivide a large problem into several smaller tasks or parts for ease of analysis.
▪ Top-down analysis, therefore, simplifies or reduces the complexity of the process of problem solving.
▪ It is not limited by the type of program. Top-down analysis is a general method for attending to any problem.
▪ It provides a strategy that has to be followed for solving all problems.

▪There are two essential ideas in top-down analysis:


▪ subdivision of a problem
▪ hierarchy of tasks

Modular Programming:
▪Modular programming is a program that is divided into logically independent smaller sections, which can be written
separately.
▪These sections, being separate and independent units, are called modules.
▪ A module consists of a series of program instructions or statements in some programming language.
▪ A module is clearly terminated by some special markers required by the syntax of the language. For example, a BASIC language
subroutine is terminated by the return statement.
▪ A module as a whole has a unique name.
▪ A module has only one entry point to which control is transferred from the outside and only one exit point from which control is returned to
the calling module. The following are some of the advantages of modular programming.
▪ Complex programs may be divided into simpler and more manageable elements.

73
Structured Code:
▪After the top-down analysis and design of the modular structure, the third and final phase of structured programming involves
the use of structured code.
▪Structured programming is a method of coding, i.e., writing a program that produces a well-organized module.

▪A high-level language supports several control statements, also called structured control statements or structured code, to
produce a well-organized structured module.
Process of Programming:
▪There are some logical and sequential job steps which the programmer has to follow to make the program operational.

▪These are as follows:


▪ Understand the problem to be solved
▪ Think and design the solution logic
▪ Write the program in the chosen programming language
▪ Translate the program to machine code
▪ Test the program with sample data
▪ Put the program into operation

74
Example:

75
Example:

76
Example:

77
Example:

78
Example:
Prepare a flowchart to read the marks of a
student and classify them into different
grades. If the marks secured are greater
than or equal to 90, the student is awarded
Grade A; if they are greater than or equal to
80 but less than 90, Grade B is awarded; if
they are greater than or equal to 65 but less
than 80, Grade C is awarded; otherwise
Grade D is awarded.

79
80
81

You might also like