Post on 04-Jun-2018
8/13/2019 Engineering CP unit I
1/41
C ProgrammingLecture NotesUnit 1
Page 1 of 41
UNIT1
INTRODUCTION
1.1.INTRODUCTION TO COMPUTER1.1.1. OVERVIEW OF COMPUTERS
The term Computer is derived from the Latin word Computare which means to
Compute or to Calculate, so it is considered to be a calculating device.
In fact, the main objective of inventing computer was to create a fast calculating machine.
But now-a-days more than 75% of non-mathematical or non-numerical work is carried
out by the computers.
1.1.1.1.Definition
Computer is a fast operating electronic device which automatically accepts and stores
input data, processes them and produces the desired output.
(Or)
Computer is an electronic device which processes information based on the instructions
provided, to generate the desired output. It, therefore, requires two types of input raw
data, and the set of instructions to process or act upon the data.
Figure: Processing Information
Data can be of any type text, numeric, alpha-numeric, image, picture, sound etc. The
instructions that act upon this data are also called the programor softwarein computer
terminology.
1.1.1.2.Data & Information
Data: It is the facts about anything
Information: The processed data or collection of data is called information.
Computer can store, process and retrieve such data or information as and when required.
Process
Instructions
Data
Out ut
Input
8/13/2019 Engineering CP unit I
2/41
C ProgrammingLecture NotesUnit 1
Page 2 of 41
1.1.1.3. Basic operations of a computer:
The computer has the following five basic operations to carry out any task.
i. Input: It is the process of capturing data for the processing.
ii. Process: It is the transformation and manipulation process to convert the input in
to output.
iii. Output: It is the result, which comes from the transformation process or it is the
outcome of the process.
iv. Storing: It is the process of saving the data, instructions, and information, so that
they can be retained and retrieved whenever required.
v. Controlling: It is the process of directing the manner and sequence in which all
the operations are to be performed.
1.1.1.4.Comparison of using computer with human being and calculator
A) Comparison of using computer with human being The computer can perform any arithmetic task with high speed which a man cannot
perform. The advantage of using computer is that it can execute tasks with more accuracy
and speed than human being.
Human being is not restricted by any limits, but computer is restricted by limited step-by-
step instructions called program. Human being can think reason and discover, but the
computer can simply compare, calculate and manipulate.
S.No Characteristic Human Computer
1. Speed Very slow Fast and excellent
2. Accuracy Possibility for error Makes no error
3. Performance Poor Very good
4. Instructions Chances for imperfect Follow perfect
5. Remember Inaccurate Accurate and exact
6. Diligency Human High
B) Comparison of using computer with calculator Unlike a man who is bound to commit mistake, the calculator can do long calculation
with 100% accuracy. The calculator is perfect and it is free from mistake.
8/13/2019 Engineering CP unit I
3/41
C ProgrammingLecture NotesUnit 1
Page 3 of 41
S.No Characteristic Calculator Computer
1. Speed Fast Much faster
2.Performance
Simple calculations and
numeric processing
Complex problem and non-
numeric processing
3.Memory
Less internal memory and nopermanent storage, temporary
storage only
Large internal memory andlarge permanent storage
available
4. Machine Electronic device Electronic device
5. Operation Arithmetic Arithmetic and logical
1.1.2.CHARACTERISTICS OF COMPUTERSThe characteristics of computers that have made them so powerful and universally useful
are speed, accuracy, diligence, versatility and storage capacity.
Speed
Computers work at an incredible speed. The speed with which it performs is way beyond
human capabilities. As a comparison, it can do in one minute what a human being would
probably take year!
The following are the measurements by which the speed of a computer is measured.
1 millisecond = 110-3
second
1 microsecond= 110-6
second
1 nanosecond =110-9
second
1 picoseconds = 110-12
second
We do not measure speed in seconds or in milli seconds today, we measure speed in nano
second and pico second. A powerful computer is capable of adding together two 20-digit
numbers in 300 nano seconds.
Accuracy
In addition to being fast, computers are also accurate. Errors that may occur can almost
always be attributed to human error (inaccurate data, poorly designed system or faulty
instructions/programs written by the programmer) rather than technological weaknesses.
In fact, a special term GIGO (Garbage In Garbage Out) has been coined to represent a
scenario where faulty results are got due to inaccurate instructions or faulty data.
8/13/2019 Engineering CP unit I
4/41
C ProgrammingLecture NotesUnit 1
Page 4 of 41
Automatic
A computer works automatically, once programs are stored and data are given to it,
constant supervision is not required.
Diligence
Unlike human beings, computers are highly consistent. They do not suffer from human
traits of boredom and tiredness resulting in lack of concentration. Computers, therefore,
score high over human beings in performing voluminous and repetitive jobs.
If three million calculations have to be performed, it will perform the third millionth
instruction with exactly the same accuracy and speed as the first instruction.
Versatility
A computer canbe put to work in various fields. As is evident, in todays fast developing
technology-world, it is almost inconceivable to find an area where computers are not
being used. The presence of computers can be seen in every sphere Railway/Air
reservation, Banks, Hotels, Weather forecasting and many more.
Storage Capacity
Todays computers can store volumes of data. Unlike human memory where unimportant
information is relegated to the back of the mind and forgotten as time progresses, a piece
of information once recorded (or stored) in the computer, can never be forgotten and can
be retrieved almost instantaneously! Information can, therefore, be retained as long as
desired (using secondary storagea type of detachable memory).
Reduction of cost
Though initial investment may be high, computer substantially reduces the cost of
transaction.
No intelligent quotient
The computer cannot think of its own and it can duly perform the instructions given by
the human being.
1.1.3.APPLICATIONS OF COMPUTER Following list demonstrates the various applications of Computers in today's arena.
Business
The computer's characteristic as high speed of calculation, diligence, accuracy, reliability,
or versatility has made it an integrated part in all business organisations.
8/13/2019 Engineering CP unit I
5/41
C ProgrammingLecture NotesUnit 1
Page 5 of 41
Computer used in business organisation for:
Payroll Calculations
Budgeting
Sales Analysis
Financial forecasting
Managing employees database
Maintenance of stocks etc.
Banking
Today Banking is almost totally dependent on computer.
Banks provide following facilities:
Banks on-line accounting facility, which include current
balances, deposits, overdrafts, interest charges, shares
and trustee records.
ATM machines are making it even easier for customers to
deal with banks.
Insurance
Insurance companies are keeping all records up to date with the help of computer. The
Insurance Companies, Finance houses and Stock broking firms are widely using
computers for their concerns.
Insurance Companies are maintaining a database of all clients with information showing
how to continue with policies
starting date of the policies
next due installment of a policy
maturity date
interests due
survival benefits
bonus
8/13/2019 Engineering CP unit I
6/41
C ProgrammingLecture NotesUnit 1
Page 6 of 41
Education
The computer has provided a lot of facilities in the Education System.
The uses of computer provide a tool in the Education system is known as CBE
(Computer Based Education).
CBE involves Control, Delivery and Evaluation of learning.
The computer education is very familiar and rapidly increasing
the graph of computer students.
There are number of methods in which educational institutions
can use computer to educate the students.
It is used for prepare a database about student performance and analysis are carried out.
Marketing
In Marketing uses of computer are following:
Advertising:With computers, advertising professionals create art and graphics, write and
revise copy, and print and disseminate ads with the goal of selling more products.
At Home Shopping:At home shopping has been made possible through use of
computerised catalogues that provide access to product information and permit direct
entry of orders to be filled by the customers.
Health Care
Computers have become important part in all Medical Systems.
The computers are being used in hospitals to keep the record of patients and medicines. It
is also used in scanning and diagnosing different diseases. ECG, EEG, Ultrasounds and
CT Scans etc. are also done by computerised machines.
Some of major fields of health care in which computer are used:
8/13/2019 Engineering CP unit I
7/41
C ProgrammingLecture NotesUnit 1
Page 7 of 41
Diagnostic System:Computers are used to collect data and identify cause of
illness.
Lab-diagnostic System:All tests can be done and reports are prepared by
computer.
Patient Monitoring System:These are used to check patient's signs for
abnormality such as in Cardiac Arrest, ECG etc.
Pharma Information System:Computer checks Drug-Labels, Expiry dates,
harmful drug side effects etc.
Nowadays, computers are also used in performing surgery.
Engineering Design
Computers are widely used in Engineering purposes.
One of major areas is CAD(Computer aided design).CAD provides creation,edition, and
modification of image. Some fields are:
Structural Engineering:Requires stress and strain analysis required for
design of Ships, Buildings, Budgets, Airplanes etc.
Industrial Engineering:Computers deals with design, implementation
and improvement of Integrated systems of people, materials and
equipments.
Architectural Engineering:Computers help in planning towns, designing
buildings, determining a range of buildings on a site using both 2D and 3D
drawings.
8/13/2019 Engineering CP unit I
8/41
C ProgrammingLecture NotesUnit 1
Page 8 of 41
Military
Computers are largely used in defence.Modern tanks, missiles, weapons etc.employ
computerised control systems.Some military areas where a computer has been used are:
Missile Control
Military Communication
Military operation and planning
Smart Weapons
Communication
Communication means to convey a message, an idea, a picture or speech that is received
and understood clearly and correctly by the person for whom it is meant.Some main areas
in this category are:
Chatting
Usenet
FTP
Telnet
Video-conferencing
8/13/2019 Engineering CP unit I
9/41
C ProgrammingLecture NotesUnit 1
Page 9 of 41
Government Applications
Computers play an important role in government applications. Some major fields in this
category are:
Budgets
Sales tax department
Income tax department
Male/Female ratio
Computerization of voters lists
Computerization of Driving Licensing system
Computerization of PAN card
Weather Forecasting.
1.1.4.EVOLUTION OF COMPUTERS The history of computers can be traced back to almost 2000 years ago, with the advent of
abacus, a wooden rack holding two horizontal wires with beads strung on them.
Numbers are represented using the position of beads on the rack. Fast and simple
calculations can be carried out by appropriately placing the beads.
In 1620, an English mathematician by the name Wil liam Oughtredinvented the slide rule
a calculating device based on the principle of logarithms. It consisted of two graduated
scales devised in such a manner that suitable alignment of one scale against the other,
made it possible to perform additions, compute products etc. just by inspection.
Figure: The Abacus
Blaise Pascal, a French mathematician, is usually credited for building the first digital
computer in 1642. He invented the mechanical calculating machine. Numbers were
8/13/2019 Engineering CP unit I
10/41
C ProgrammingLecture NotesUnit 1
Page 10 of 41
entered in this machine by dialing a series of numbered wheels. Another series of toothed
wheels transferred the movements to a dial, which showed the results.
In 1671, Gottfried von Leibnitz, a German mathematician, invented a calculating
machine which was able to add and perform multiplications. He invented a special
stepped gear mechanism for introducing the addend digits, which is still being used.
The prototypes made by Pascaland Leibnitzwere not used in many places. It was only
about a century later that Thomas of Colmar created the first successful mechanical
calculator which could add, subtract, multiply, and divide. A lot of improved desktop
calculators by various inventors followed, such that by 1890 a range of improvements
like accumulation of partial results, storage of past results, and printing of results were
not uncommon.
The First Computer
Charles Babbage, a professor of mathematics at Cambridge University, England,
realized that many long calculations usually consisted of a series of actions that were
constantly repeated and hence could possibly be automated. By 1822, he designed an
automatic calculating machine that he called the Difference Engine. It was intended to
be steam powered and fully automatic (including printing of result tables), commanded
by a fixed instruction program. In short, he developed a prototype of a computer which
was 100 years ahead of time and is, therefore, considered as the father of modern day
computers.
A step towards automated computing was the development of punched cards which were
first successfully used by Herman Holleri th, who worked in the US Census Bureauin
1890. He along with James Powersdeveloped devices that could read information that
had been punched into cards, without any human help. This resulted in reduced readingerrors, increased workflow and availability of unlimited memory (punched cards could be
used as easily accessible memory of unlimited size).
These advantages were seen by various commercial companies and soon led to the
development of improved punch-card using computers by companies like International
Business Machines (IBM) and Remington.
Some Well Known Early Computers
Mark I
After World War II there was a need felt for advanced calculations. By that time, many
reliable mechanical desk calculators had been developed. Howard A. Aikenof Harvard
University, while working on his doctorate in physics, in the year 1937, designed a
machine that could automatically perform a sequence of arithmetic operations. He
completed this in 1944 and named it Mark I. This machine performed a multiplication
and division at an average of about four and eleven seconds respectively. The results
were printed at a rate of one result per five seconds.
8/13/2019 Engineering CP unit I
11/41
C ProgrammingLecture NotesUnit 1
Page 11 of 41
ENIAC
The World War II also produced a large need for computer capacity especially for the
military. New weapons were made for which trajectory tables and other essential data
were needed. In 1942, Professors
John P. Eckert and John W. Mauchly at the Moore School of Engineering of the
University of Pennsylvania, USA, decoded to build a high speed computer to do the job.This was called the Electronic Numeric Integrator and Calculator (ENIAC).
It used 18,000 vacuum tubes, about 1,800 square feet of floor space, and consumed about
180,000 watts of electrical power. It had punched cards I/O and its programs were wired
on boards.
ENIAC is accepted as the first successful high-speed electronic digital computer and was
used from 1946 to 1955.
EDVAC
Fascinated by the success of ENIAC, John Von Neumann, a mathematician, undertookan abstract study of computation in 1945. In this he aimed to show that a computer
should be able to execute any kind of computation by means of a proper programmed
control. His ideas, referred to as stored program technique, became essential for
future generations of high-speed digital computers and were universally accepted. The
basic idea behind the stored program concept was that data as well as instructions can be
stored in the computers memory to enable automatic flow of operations.
Between 1947 and 1950, the More School personnel and the Ballistics Research
Laboratory of the US army built a computer named Electronic Discrete Variable
Automatic Computer (EDVAC), which was based on Von Neumanns concept of storedprogram.
UNIVAC
The Universal Automatic Computer (UNIVAC), developed in 1951, was the first digital
computer to be produced and was installed in the Census Bureau.
The first-generation stored-program computers needed a lot of maintenance, reached 70%
to 80% reliability of operations and were used for almost 10 years. EDVAC and
UNIVAC fell into this group of computers and were the first commercially available
computers.
1.1.5.GENERATIONS OF COMPUTERS Generation in computer terminology is a step ahead in technology. As you go through
the history of evolution of computers, you will find that the earliest computers were big
in size, consumed a lot of power and heated up quickly, due to which it had to be shut
8/13/2019 Engineering CP unit I
12/41
C ProgrammingLecture NotesUnit 1
Page 12 of 41
down, frequently to be cooled. They were very expensive in terms of development and
maintenance.
As technology improved, computers became compact, faster and more powerful. From a
users perspective, they become user friendly and more affordable. This has largely
contributed towards the popularity that computers have gained these days.
The term generation was earlier used only to distinguish between varying hardware
technologies but was later extended to include both hardware and software. A
comparison of generations is made below.
First Generation Computers (1940 to 1956)
The first generation of computers was characterized by vacuum tubes in the circuitry
and magnetic drums for memory.
These computers were enormous in size, used great deal of electricity and were expensive
to operate. They also had limited storage capacity.
Figure : Vacuum Tube
First generation computers relied on machine language (binary-coded program) to
perform operations and could solve only one problem at a time. Punched cards and paper
tapes were used to input data and instructions, and output was displayed on printouts.
Early computers like ENIAC, EDVAC and UNIVAC can all be classified as first
generation computers.
Second Generation Computers (1956 to 1963)
In the early 1950s, the discoveries of Transistorand Magnetic corememory changed
the image of computers from unreliable to highly reliable machines with increased
capability, and higher storage capacity.
The transistor was far superior to the vacuum tube, allowing computers to become
smaller in size, cheaper, reliable and more energy efficient. Though transistor still
generated a great deal of heat, it was a substantial improvement over the vacuum tube.
Second generation of computers was also characterized by allowing programmers to
specify instructions in symbolic (or assembly) language rather than cryptic binary
8/13/2019 Engineering CP unit I
13/41
C ProgrammingLecture NotesUnit 1
Page 13 of 41
machine language. High level programming languages like COmmon Business Oriented
Language (COBOL) and FORmula TRANslation (FORTRAN) were also being
developed at this time.
Due to the increase in the cost of expanding programming, these machines were
expensive to purchase and operate. Such computers were, therefore, mostly found in
large computer centres or government/private laboratories with many programmers andsupport professionals.
Third Generation Computers (1964 to 1971)
The development of Integrated Circuitby Jack Kilby, an engineer with Texas
Instruments, in 1958, was the hallmark of the third generation of computers. Punched
cards and printouts gave way to devices like keyboards and monitors making it easier for
the user to interact with the computer. Computer manufacturers could provide a range of
accessories like the cathode ray tube display devices, page printers, consoles etc.
Existence of an operating systemallowed the device to run various applications at one
time with the central program monitoring the memory.
For the first time, computers were being widely used in business for areas like :
Accounting
Payroll
Billing
Tracking Inventory, etc.
Third generation computers were substantially smaller and cheaper than their
predecessors.
Fourth Generation Computers (1971 to present)
The trend in 1970s was to move from single-purpose but powerful computers towards
cheaper computer systems that could support a large range of applications.
A new revolution in computer hardware came about which could shrink the computer
logic circuitry and its components using the Large Scale Integration (LSI) technology.
Hundreds of components could now fit onto a single chip!
Figure : IC Chips Figure : Intel Pentium Microprocessor Chip
8/13/2019 Engineering CP unit I
14/41
C ProgrammingLecture NotesUnit 1
Page 14 of 41
In the 1980s, Very Large Scale Integration (VLSI) squeezed hundreds of thousands of
components onto a single chip. This shrinking trend continued and led to the introduction
of personal computers (PCs) programmable machines that are small enough and
inexpensive so that these can be purchased and used by individuals. Companies like
Apple Computers and IBM introduced very successful PCs.
The IC technology was not only used to construct the processor, but also for theconstruction of memory. The first memory chip was constructed in 1970 and could hold
256 bits.
Fifth Generation Computers (the Road Ahead)
The fifth generation of computers characterized by artificial intelligence is in the process
of development. The goal here is to develop devices that are capable of learning and
responding to natural language input. This generation of computers is using new
technologies in very large scale integration, along with new programming languages and
will be capable of amazing feats, in the area of artificial intelligence, such as voice
recognition.
Computer
Generation
Technology
Used
Speed Storage
Capacity
Programming
Language
First Vacuum tubes Slow Limited Symbolic language
Second Transistors Relatively
faster
Increased
storage
capacity
High Level Languages
(e.g. COBOL,
FORTRAN)
Third IntegratedCircuits (ICs)
Betterperformance,
Remote
processing and
time sharing
Increasedstorage
Extensive use of HighLevel Languages
Fourth Large scale and
very large scale
integrated
circuits (LSI,
VLSI)
Considerably
faster
Increased
storage
Sophisticated
programs and
languages for special
applications
Fifth Use of ICs with
ultra large scale
integration
technology
(ULSI)
Extremely fast Larger
capacity
storage
(RAID,
optical
disks)
Based on Artificial
Intelligence
8/13/2019 Engineering CP unit I
15/41
C ProgrammingLecture NotesUnit 1
Page 15 of 41
1.1.6.CLASSIFICATION OF COMPUTERSi) On the basis of working principle
a) Analog Computer
An analog computer is a form of computer that uses continuous physical phenomena such as
electrical, mechanical, or hydraulic quantities to model the problem being solved.Eg: Thermometer, Speedometer, Petrol pump indicator, Multimeter
b) Digital Computer
A computer that performs calculations and logical operations with quantities represented as
digits, usually in the binary number system.
c) Hybrid Computer (Analog + Digital)
A combination of computers those are capable of inputting and outputting in both digital andanalog signals. A hybrid computer system setup offers a cost effective method of performing
complex simulations. The instruments used in medical science lies in this category.
ii) On the basis of Size
a) Super ComputerThe fastest type of computer. Supercomputers are very expensive and are employed for
specialized applications that require immense amounts of mathematical calculations. For
example, weather forecasting requires a supercomputer. Other uses of supercomputers include
animated graphics, fluid dynamic calculations, nuclear energy research, and petroleum
exploration. PARAM, Pace & Flosolver are the supercomputer made in india.
8/13/2019 Engineering CP unit I
16/41
C ProgrammingLecture NotesUnit 1
Page 16 of 41
b)Mainframe Computer
A very large and expensive computer capable of supporting hundreds, or even thousands, of
users simultaneously. In the hierarchy that starts with a simple microprocessor (in watches, for
example) at the bottom and moves to supercomputers at the top, mainframes are just below
supercomputers. In some ways, mainframes are more powerful than supercomputers because
they support more simultaneous programs. But supercomputers can execute a single program
faster than a mainframe.
c) Mini Computer
A midsized computer. In size and power, minicomputers lie between workstations and
mainframes. In the past decade, the distinction between large minicomputers and small
mainframes has blurred, however, as has the distinction between small minicomputers and
workstations. But in general, a minicomputer is a multiprocessing system capable of supporting
from 4 to about 200 users simultaneously. Generally, servers are comes in this category.
d) Micro Computer
i. Desktop Computer:a personal or micro-mini computer sufficient to fit on a desk.
ii. Laptop Computer: a portable computer complete with an integrated screen andkeyboard. It is generally smaller in size than a desktop computer and larger than a
notebook computer.
iii. Palmtop Computer/Digital Diary /Notebook /PDAs: a hand-sized computer.
Palmtops have no keyboard but the screen serves both as an input and output device.
8/13/2019 Engineering CP unit I
17/41
C ProgrammingLecture NotesUnit 1
Page 17 of 41
e) Workstations
A terminal or desktop computer in a network. In this context, workstation is just a generic term
for a user's machine (client machine) in contrast to a "server" or "mainframe."
1.1.7.BASIC COMPUTER ORGANIZATION The computer system essentially comprises three important parts input device, central
processing unit (CPU) and the output device. The CPU itself is made of three
components namely, the arithmetic logic unit (ALU), memory unit, and the control unit.
In addition to these, auxiliary storage/secondary storage devices are used to store data and
instructions on a long-term basis.
Figure: Basic Computer Organization
Input Unit
Data and instructions must be entered into the computer system for processing, and
results obtained from computations must be displayed or recorded for the user. The input
device serves the purpose of receiving data and instructions in a form that can be
understood by the computer.
Secondary
Storage
Input Unit Output Unit
Central Processing Unit
Arithmetic
Logic Unit
Main
Memory
Control Unit
8/13/2019 Engineering CP unit I
18/41
C ProgrammingLecture NotesUnit 1
Page 18 of 41
Central Processing Unit
Data and instructions (programs) are stored in the computers memory after which all the
major calculations and computations are carried out within the CPU. The CPU is also
responsible for controlling the operations of various units of the computer system.
a) Arithmetic Logic Unit (ALU) All calculations and comparisons, based on the instructions provided, are carried out
within the ALU. It performs arithmetic functions like addition, subtraction,
multiplication, division and also logical operations like greater than, less than and equal
to.
b) Main Memory The main memory holds data and instructions after input, till they are needed. It also
holds the processed results that are awaiting output.
c) Control Unit The function of the control unit is to execute the instructions of a program, one by one, in
the desired sequence. It interprets each instruction and then prompts its execution by one
of the units like input, output, ALU, storage.
For example, a comparison of two numbers (a logical operation) to be performed by the
ALU may require loading the two numbers into the main memory which is a function
performed by the control unit. It will then pass on the execution of the compare function
to the ALU.
Output Unit
The processed data, stored in the memory of the computer is sent to the output unit,
which then converts it into a form that can be understood by the user. The output is
usually produced in one of the two wayson the display device, or on paper (hard copy).
Secondary Storage
Also termed as auxiliary or backup storage, it is typically used as a supplement to
main storage. It is much cheaper than the main storage and stores large amount of data
and instructions permanently. Hardware devices like magnetic tapes and disks fall under
this category.
1.1.8.COMPONENTS OF COMPUTERSINPUT AND OUTPUT DEVICES
The computer will be of no use unless it is able to communicate with the outside world.
Input/Output devices are required for users to communicate with the computer. In simple
terms, input devices bring information INTO the computer and output devices bring
8/13/2019 Engineering CP unit I
19/41
C ProgrammingLecture NotesUnit 1
Page 19 of 41
information OUT of a computer system. These input/output devices are also known as
peripheralssince they surround the CPU and memory of a computer system.
Some commonly used Input/Output devices are listed in table below.
Input Devices Output Devices
Keyboard
Mouse
Joystick
Scanner
Light Pen
Touch Screen
Monitor
LCD
Printer
Plotter
Input Devices
Keyboard
It is a text base input device that allows the user to input alphabets, numbers and other
characters. It consists of a set of keys mounted on a board.
Figure : Qwerty Keyboard Layout
Alphanumer ic Keypad
It consists of keys for English alphabets, 0 to 9 numbers, and special characters like + /
* ( ) etc.
Function Keys
There are twelve function keys labeled F1, F2, F3, , F12. The functions assigned tothese keys differ from one software package to another. These keys are also user
programmable keys.
Special-f unction Keys
These keys have special functions assigned to them and can be used only for those
specific purposes. Functions of some of the important keys are defined below.
Function Keys
Numeric Keypad
Cursor Movement
Keys
Alphanumeric Keypad/
Special-function Keys
8/13/2019 Engineering CP unit I
20/41
C ProgrammingLecture NotesUnit 1
Page 20 of 41
Enter: It is similar to the return key of the typewriter and is used to execute a command
or program.
Spacebar: It is used to enter a space at the current cursor location.
Backspace: This key is used to move the cursor one position to the left and also delete the
character in that position.
Delete: It is used to delete the character at the cursor position.
Insert: Insert key is used to toggle between insert and overwrite mode during data entry.
Shift: This key is used to type capital letters when pressed along with an alphabet key.
Also used to type the special characters located on the upper-side of a key that has two
characters defined on the same key.
Caps Lock: Cap Lock is used to toggle between the capital lock feature. When on, it
locks the alphanumeric keypad for capital letters input only.
Tab: Tab is used to move the cursor to the next tab position defined in the document.
Also, it is used to insert indentation into a document.
Ctrl: Control key is used in conjunction with other keys to provide additional
functionality on the keyboard.
Alt: Also like the control key, Alt key is always used in combination with other keys to
perform specific tasks.
Esc: This key is usually used to negate a command. Also used to cancel or abort
executing programs.
Numeric Keypad: Numeric keypad is located on the right side of the keyboard and
consists of keys having numbers (0 to 9) and mathematical operators (+
* /) defined onthem. This keypad is provided to support quick entry for numeric data.
Cursor Movement Keys: These are arrow keys and are used to move the cursor in the
direction indicated by the arrow (up, down, left, right).
Mouse
The mouse is a small device used to point to a particular place on the screen and select in
order to perform one or more actions. It can be used to select menu commands, size
windows, start programs etc.
The most conventional kind of mouse has two buttons on top: the left one being used
most frequently.
Mouse Actions
Left Click : Used to select an item.
Double Click :Used to start a program or open a file.
Right Click : Usually used to display a set of commands.
8/13/2019 Engineering CP unit I
21/41
C ProgrammingLecture NotesUnit 1
Page 21 of 41
Drag and Drop :It allows you to select and move an item from one location to
another. To achieve this place the cursor over an item on the screen, click the left
mouse button and while holding the button down move the cursor to where you want
to place the item, and then release it.
Joystick
The joystick is a vertical stick which moves the graphic cursor in a direction the stick is
moved. It typically has a button on top that is used to select the option pointed by the
cursor. Joystick is used as an input device primarily used with video games, training
simulators and controlling robots.
Figure : Mouse Figure : Joystick
Scanner
Scanner is an input device used for direct data entry from the source document into the
computer system. It converts the document image into digital form so that it can be fed
into the computer. Capturing information like this reduces the possibility of errors
typically experienced during large data entry.
Figure : A Flat-bed Scanner
Hand-held scanners are commonly seen in big stores to scan codes and price informationfor each of the items.
Light Pen
It is a pen shaped device used to select objects on a display screen. It is quite like the
mouse (in its functionality) but uses a light pen to move the pointer and select any object
on the screen by pointing to the object.
8/13/2019 Engineering CP unit I
22/41
C ProgrammingLecture NotesUnit 1
Page 22 of 41
Users of Computer Aided Design (CAD) applications commonly use the light pens to
directly draw on screen.
Touch Screen
It allows the user to operate/make selections by simply touching the display screen.
Common examples of touch screen include information kiosks, and bank ATMs.
Output Devices
Monitor
Monitor is an output device that resembles the television screen and uses a Cathode Ray
Tube (CRT) to display information. The monitor is associated with a keyboard for
manual input of characters and displays the information as it is keyed in. It also displays
the program or application output. Like the television, monitors are also available in
different sizes.
Figure : Monitor
L iquid Crystal Display (LCD)
LCD was introduced in the 1970s and is now applied to display terminals also. Its
advantages like low energy consumption, smaller and lighter have paved its way for
usage in portable computers (laptops).
Printer
Printers are used to produce paper (commonly known as hardcopy) output. Based on the
technology used, they can be classified as Impactor Non-impactprinters.
Impact printersuse the typewriting printing mechanism wherein a hammer strikes the
paper through a ribbon in order to produce output. Dot-matrix and Character printers fall
under this category.
8/13/2019 Engineering CP unit I
23/41
C ProgrammingLecture NotesUnit 1
Page 23 of 41
Non-impactprinters do not touch the paper while printing. They use chemical, heat
or electrical signals to etch the symbols on paper. Inkjet, Deskjet, Laser, Thermal
printers fall under this category of printers.
When we talk about printers we refer to two basic qualities associated with printers:
resolution, and speed. Print resolutionis measured in terms of number of dots per
inch (dpi). Print speedis measured in terms of number of characters printed in aunit of time and is represented as characters-per-second (cps), lines-per-minute
(lpm), or pages-per-minute (ppm).
Plotter
Plotters are used to print graphical output on paper. It interprets computer commands
and makes line drawings on paper using multicoloured automated pens. It is capable
of producing graphs, drawings, charts, maps etc.
Figure : An Inkjet Printer Figure : A Flatbed Plotter
Computer Aided Engineering (CAE) applications like CAD (Computer Aided Design)
and CAM (Computer Aided Manufacturing) are typical usage areas for plotters.
RAM/ROM
Computers memory can be classified into two types RAM and ROM.
RAMor Random Access Memory is the central storage unit in a computer system. It is
the place in a computer where the operating system, application programs and the data in
current use are kept temporarily so that they can be accessed by the computers
processor. The more RAM a computer has, the more data a computer can manipulate.
Random access memory, also called the Read/Write memory, is the temporary memory
of a computer. It is said to be volatile since its contents are accessible only as long asthe computer is on. The contents of RAM are cleared once the computer is turned off.
ROMor Read Only Memory is a special type of memory which can only be read and
contents of which are not lost even when the computer is switched off. It typically
contains manufacturers instructions. Among other things, ROM also stores an initial
program called the bootstrap loader whose function is to start the computer software
operating, once the power is turned on.
8/13/2019 Engineering CP unit I
24/41
C ProgrammingLecture NotesUnit 1
Page 24 of 41
Read-only memories can be manufacturer-programmedor user-programmed. While
manufacturer-programmed ROMs have data burnt into the circuitry, user-programmed
ROMs can have the user load and then store read-only programs. PROM or
Programmable ROM is the name given to such ROMs.
Information once stored on the ROM or PROM chip cannot be altered. However, another
type of memory called EPROM (Erasable PROM) allows a user to erase the informationstored on the chip and reprogram it with new information. EEPROM (Electrically
EPROM) and UVEPROM (Ultra Violet EPROM) are two types of EPROMs.
SECONDARY STORAGE DEVICES
RAM is volatile memory having a limited storage capacity. Secondary/auxiliary storage
is storage other than the RAM. These include devices that are peripheral and are
connected and controlled by the computer to enable permanent storage of programs and
data.
Magnetic medium was found to be fairly inexpensive and long lasting medium and,
therefore, became the preferred choice for auxiliary storage. Floppy disks and hard disks
fall under this category. The newer forms of storage devices are optical storage devices
like CDs, DVDs, Pen drive, Zip drive etc.
Floppy Disk
These are small removable disks that are plastic coated with magnetic recording material.
Floppy disks are typically 3.5 in size (diameter) and can hold 1.44 MB of data. This
portable storage device is a rewritable media and can be reused a number of times.
Floppy disks are commonly used to move files between different computers. The main
disadvantage of floppy disks is that they can be damaged easily and, therefore, are not
very reliable.
Hard Disk
Hard disks are made up of rigid material and are usually a stack of metal disks sealed in a
box. The hard disk and the hard disk drive exist together as a unit and are a permanent
part of the computer where data and programs are saved. These disks have storage
capacities ranging from 1GB to 80 GB and more. Hard disks are also rewritable and are
more reliable when compared with floppies.
Figure : A Floppy Disk Figure : A Winchester Disk
8/13/2019 Engineering CP unit I
25/41
C ProgrammingLecture NotesUnit 1
Page 25 of 41
Depending on the way they are packaged, hard disks can be classified as Disk packsor
Winchester disks. Disk packs are removable, in the sense that they can be removed and
kept offline when not in use. They must be mounted on the disk drive before use.
Winchester disks on the other hand, consist of disk platters sealed in a contamination-free
container and form a permanent component of the computer.
CD
Compact Disk (CD) is portable disk having data storage capacity between 650-700 MB.
It can hold large amount of information such as music,
full-motion videos, and text etc. It contains digital information that can be read, but
cannot be rewritten. Separate drives exist for reading and writing CDs.
Since it is a very reliable storage media, it is very often used as a medium for distributing
large amount of information to large number of users. In fact today most of the software
is distributed through CDs.
DVD
Digital Versatile Disk (DVD) is similar to a CD but has larger storage capacity and
enormous clarity. Depending upon the disk type it can store several Gigabytes of data (as
opposed to around 650MB of a CD). DVDs are primarily used to store music or movies
and can be played back on your television or the computer too. They are not rewritable
media.
1.2.COMPUTER SOFTWARE:
Software is a set of programs, which is designed to perform a well defined function. A programis a sequence of instruction written to solve a particular problem.
TYPES OF SOFTWARE:
1. System software
2.Application software
SYSTEM SOFTWARE
System software directly controls the computers hardware, whereas application software
is one level removed from hardware. System software manages the computers resources,
enables the various components of the computer to communicate, runs application software, and
makes the hardware respond to the users needs. When the system software operates efficiently,
the difficult operations of controlling the hardware are transparent to the user. System software
includes four main types:
8/13/2019 Engineering CP unit I
26/41
C ProgrammingLecture NotesUnit 1
Page 26 of 41
The operating systemprovides an interface between the computer hardware and the user
or the application software. Because of its central importance, the operating system will
be discussed in more detail below.
Language translators convert application programs and any other software programs
into the machine language that actually controls the computer's operations.
assemblers translates the program in assembly-languageinto machine-language
compilers translates high-levellanguage program into machine-languageall at once
interpreters translates high-levellanguage into machine-languagea line at a time
Network and communications software operates the communications hardware in a
computer so that it can transmit and receive information from other computers. Network
and communications software requires two types of software: software for the PC
operating system and software for the network operating system. In some cases, the latter
comes built-in the former. Utility programs perform various specialized "housekeeping" tasks, such as file
management, virus protection, disk defragmentation, program installation and
uninstallation, file and disk back up, disk formatting, and providing screen saver
programs. This list is far from exhaustive. The user directly controls most utility
programs, although some utility programs can be set to run automatically (e.g.; screen
savers and anti-virus scanning).
APPLICATION SOFTWARE
Application software can be written for a specific users application (custom software), or
it can be mass-produced for general use (commercial or packaged software).Word processingprograms allow the user to quickly and easily create and revise texts
on the computer screen. By using word processing applications, the user can format documents
with ease, changing font size, margins, color, etc. Different types of documentse.g., letters,
memos, and reportsare often preformatted in the application. PC-based word processingsoftware is so capable and inexpensive that, in most businesses, it has become the usual tool for
creating documents, even when more powerful mainframes and minicomputers are available.
Spreadsheet programsare especially useful in business and accounting. The electronic
spreadsheet consists of rows and columns of data, which the user can easily edit, copy, move, orprint. Using numeric data entered in the spreadsheet, the computer can perform numerous
mathematical calculations automatically, many of impressive sophistication (e.g., statistical,
logical, and engineering functions). One of the spreadsheet programs most powerful features forbusiness purposes is that it enables the user to do what-if analyses on existing data and to inputdifferent data for various scenarios. Non-numeric data (e.g., names and dates) may also be
entered in a spreadsheet. Spreadsheets can perform some non-mathematical operations (e.g.,
sorting and filtering) on this data, although this type of analysis is not a spreadsheet's strength.
Database software allows the user to enter, store, maintain, retrieve, and manipulate
data. In some ways, databases pickup where spreadsheets leave off, although a fairer assessment
is probably that the relationship between the two types of software is reciprocal. Database
8/13/2019 Engineering CP unit I
27/41
C ProgrammingLecture NotesUnit 1
Page 27 of 41
software is certainly more efficient and effective at handling non-numeric data than isspreadsheet software. Conversely, numeric data is usually easier to manipulate in a spreadsheet.
In most databases, data is entered to tables of rows and columns, similar to spreadsheets. Unlike
spreadsheets, these tables can be connected into relationships that allow users incredibleversatility in what they can do with that data. For example, databoth numeric and non-
numericfrom several individual tables may be retrieved and used together in calculations, with
the results presented in a business-style report.Presentation graphics software enables users to design professional-quality
presentations for business and educational purposes. The presentations usually consist of
formatted slides for projecting onto a screen from a computer projector or overhead projector, orfor display on a large monitor. These presentations may also be used for online meetings and
Web broadcasts. The slides can be designed to include backgrounds, graphic images, charts,
clipart, shading, animation, and audio effectsand, of course, text, which can sometimes get lost
in all of the embellishments.
1.3.SOFTWARE DEVELOPMENT LIFE CYCLE
The systems development life cycle (SDLC), or software development process, or Software
Development Life Cyclein systems engineering, information systems and software engineering,
is a process of creating or altering information systems, and the models and methodologies that
people use to develop these systems. In software engineering, the SDLC concept underpins many
kinds of software development methodologies.
SOFTWARE DEVELOPMENT PHASES:
Preliminary Analysis: The objective of phase 1 is to conduct a preliminary analysis, propose
alternative solutions, describe costs and benefits and submit a preliminary plan with
recommendations.
Systems analysis, requirements definition: Defines project goals into defined functions and
operation of the intended application. Analyzes end-user information needs.
Systems design: Describes desired features and operations in detail, including screen layouts,
business rules, process diagrams, pseudocode and other documentation.
Development: The real code is written here.
Integration and testing: Brings all the pieces together into a special testing environment, then
checks for errors, bugs and interoperability.
Acceptance, installation, deployment: The final stage of initial development, where the
software is put into production and runs actual business.
8/13/2019 Engineering CP unit I
28/41
C ProgrammingLecture NotesUnit 1
Page 28 of 41
Maintenance: During the maintenance stage of the Life-Cycle, the system is assessed to ensure
it does not become obsolete. This is also where changes are made to initial software. It involves
continuous evaluation of the system.
Evaluation: Some companies do not view this as an official stage of the SDLC, but is it an
important part of the life cycle. Evaluation step is an extension of the Maintenance stage, and
may be referred to in some circles as Post-implementation Review. This is where the system that
was developed, as well as the entire process, is evaluated.
Disposal Phase:In this phase, plans are developed for discarding system information, hardware
and software in making the transition to a new system. The purpose here is to properly move,
archive, discard or destroy information, hardware and software that is being replaced, in a matter
that prevents any possibility of unauthorized disclosure of sensitive data.
Software Development life cycle
1.4. NEED FOR STUDYING COMPUTER PROGRAMMING LANGUAGES
PROGRAMMING LANGUAGES:
A programming languageis a formal language designed to communicate instructions to
a machine, particularly a computer. Programming languages can be used to create programs that
control the behavior of a machine and/or to express algorithms precisely.
8/13/2019 Engineering CP unit I
29/41
C ProgrammingLecture NotesUnit 1
Page 29 of 41
TYPES OF PROGRAMMING LANGUAGES:
1. Machine Language
2. Assembly Language
3. High Level Language
1. Machine Language:
It is a native language of computers.It uses only 0s and 1s to represent data and instructions.
2. Assembly Language:An assembly languageis a low-level programming language for a computer, or other
programmable device, in which there is a very strong correspondence between the language and
the architecture's machine code instructions. Assembly language is converted into executable
machine code by a utility program referred to as an assembler; the conversion process is referred
to as assembly, or assemblingthe code.
3. High Level Language:
Aprogramming languagesuch as C, FORTRAN, or Pascalthat enables aprogrammerto
writeprogramsthat are more or less independent of a particular type of computer.Such languagesare considered high-level because they are closer to human languages and
further from machine languages. In contrast, assembly languagesare considered low-level
because they are very close to machine languages.
GENERATIONS OF PROGRAMMING LANGUAGES:
First generation:Machine Language
The first language was binary, also known as machine language, which was used in
earliest computers and machines.
OPCODE(Operation
Code)
OPERAND(Memory
Location)
The first part is an opcode, which tells the computer what functions are to be performed. The
second part is operand which tells the computer where to find or store the data on which the
desired operation is to be performed.
Advantages:
Translation free
High speed
Disadvantages:
Machine dependent Complex Language
Error prone
Tedious
Second Generation: Assembly Language
Developed on early 1950s and its main developer was IBM.
Assembly language allows the programmer to interact directly with the hardware.
8/13/2019 Engineering CP unit I
30/41
C ProgrammingLecture NotesUnit 1
Page 30 of 41
It provides mnemonic instructions usually three letters long corresponding to each
machine instructions.
Eg:ADD which is used to perform addition operation
The general format of assembly instruction is
[Label] [;comment]
Label opcode operands comments
BEGIN ADD A,B ;add B to A
(Source code) (object code)
Advantages:
Easy to understand and use
Less error prone
Faster
More control on hardware
Disadvantages:
Machine Dependent
Harder to learn
Slow development time
Less efficient
No standardization
Third Generation:High Level Language
In computer science, a high-level programming languageis a programming
language with strong abstraction from the details of the computer. In comparison to low-
level programming languages, it may use natural language elements, be easier to use, or
may automate (or even hide entirely) significant areas of computing systems (e.g.
ASSEMBLERAssembly
program
Machine
language
program
8/13/2019 Engineering CP unit I
31/41
C ProgrammingLecture NotesUnit 1
Page 31 of 41
memory management), making the process of developing a program simpler and more
understandable relative to a lower-level language.
Eg: COBOL, FORTRAN,BASIC and C.
Advantages:
Readability
Machine Independent
Easy Debugging
Easier to Maintain
Low development cost
Disadvantages:
Poor control on hardware
Less Efficient
Fourth Generation: 4GL
Commonly used to access databases.
Have minimum number of syntax rules.
Helpful to write application programs.
Three categories of 4GL:
Query Languages
Report Generators
Application Generators
Advantages:
User can create their application in a much shorter time for their development.
It does not require the programmer to provide the logic to perform a task.Disadvantages:
Programs are quite lengthy, since need more disk space and large memory capacity.
Fifth Generation:Very high languages
It is just a conceptual view of what might be the future of programming languages.
These languages will be able to process natural languages.
Need for Studying Computer Programming Languages:
Computer is a machine which cannot understand English.
Usage of Machine language to give instructions to the computer was found very difficult
by human.
Programming languages were invented to make machines easier to use and no need to
give instructions in the form of 0s and 1s.
8/13/2019 Engineering CP unit I
32/41
C ProgrammingLecture NotesUnit 1
Page 32 of 41
1.5. PROBLEM SOLVING TECHNIQUES
Problem solving technique is a set of techniques and graphical tools that helps in providing logic
for solving a problem. These tools are used to express the logic of the problem by specifying the
correct sequence of all instructions to be carried out.
1. Algorithm2. Flowchart
Algorithm
Set of step-by-step instructions that perform a specific task or operation in Natural
language
NOT programming language
Advantages of algorithm
it is a step-by-step representation of a solution to a given problem ,which is very easy to
understand
it has got a definite procedure.
it easy to first develop an algorithm, then convert it into a flowchart &then into a
computer program.
it is independent of programming language.
it is easy to debug as every step is got its own logical sequence.
Disadvantages of algorithms
Not suitable for complex problems
Cannot be updated
It is time consuming & cumbersome as algorithm is developed first which is converted intoflow chart &then into a computer program.
Flowchart
A flowchart is a schematic representation of an algorithm or a stepwise process, showing
the steps as boxes of various kinds, and their order by connecting these with arrows.
Flowcharts are used in designing or documenting a process or program.
A flow chart, or flow diagram, is a graphical representation of a process or system that
details the sequencing of steps required to create output.
A flowchart is a picture of the separate steps of a process in sequential order.
ADVANTAGES OF USING FLOWCHARTS
The benefits of flowcharts are as follows:
8/13/2019 Engineering CP unit I
33/41
C ProgrammingLecture NotesUnit 1
Page 33 of 41
1. Communication: Flowcharts are better way of communicating the logic of a system to
all concerned.
2. Effective analysis: With the help of flowchart, problem can be analyses in more
effective way.
3. Proper documentation: Program flowcharts serve as a good program documentation,
which is needed for various purposes.
4. Efficient Coding: The flowcharts act as a guide or blueprint during the systems
analysis and program development phase.
5. Proper Debugging: The flowchart helps in debugging process.
6. Efficient Program Maintenance: The maintenance of operating program becomes easy
with the help of flowchart. It helps the programmer to put efforts more efficiently on that part
LIMITATIONS OF USING FLOWCHARTS
1. Complex logic: Sometimes, the program logic is quite complicated. In that case,
flowchart becomes complex and clumsy.
2. Alterations and Modifications: If alterations are required the flowchart may require re-drawing completely.
3. Reproduction: As the flowchart symbols cannot be typed, reproduction of flowchart
becomes a problem.
4. The essentials of what is done can easily be lost in the technical details of how it is
done.
GUIDELINES FOR DRAWING A FLOWCHART
The following are some guidelines in flowcharting:
a. In drawing a proper flowchart, all necessary requirements should be listed out in
logical order.
b. The flowchart should be clear, neat and easy to follow. There should not be any room
for ambiguity in understanding the flowchart.
c. The usual direction of the flow of a procedure or system is from left to right or top to
bottom.
d. Only one flow line should come out from a process symbol.
or
e. Only one flow line should enter a decision symbol, but two or three flow lines, one for
each possible answer, should leave the decision symbol.f. Only one flow line is used in conjunction with terminal symbol.
8/13/2019 Engineering CP unit I
34/41
C ProgrammingLecture NotesUnit 1
Page 34 of 41
SYMBOLS USED IN FLOW CHART
Figure:Start/Stop terminal box
Figure:Input/output box
Figure:Process/Instruction box
Figure:Lines or Arrows
Figure:Decision box
Figure: Connector box
http://3.bp.blogspot.com/-lF6ruaOQHC0/UGyWTq_1EXI/AAAAAAAAAh0/A48lWRxi5Q8/s1600/connector_03.jpghttp://3.bp.blogspot.com/-Ffd5jluyK8Y/UGyVcmhsL5I/AAAAAAAAAhs/YM9BE4o_898/s1600/decision_03.jpghttp://3.bp.blogspot.com/-WxJxEWb6kog/UGyUKDim_3I/AAAAAAAAAhk/tIFW7IKLdHg/s1600/arrows_03.jpghttp://2.bp.blogspot.com/-_9v1CN97nDg/UGyS39rrvrI/AAAAAAAAAhc/Hp_-6eIbRIg/s1600/process_03.jpghttp://3.bp.blogspot.com/-Yid4V_bSR_c/UGyRqbo5VJI/AAAAAAAAAhU/whLrCtdgJ64/s1600/output-input_03.jpghttp://3.bp.blogspot.com/-b6TQd1_QrPw/UGyQt8YViLI/AAAAAAAAAhM/eYSjwtZ_rsI/s1600/terminal+start.jpghttp://3.bp.blogspot.com/-lF6ruaOQHC0/UGyWTq_1EXI/AAAAAAAAAh0/A48lWRxi5Q8/s1600/connector_03.jpghttp://3.bp.blogspot.com/-Ffd5jluyK8Y/UGyVcmhsL5I/AAAAAAAAAhs/YM9BE4o_898/s1600/decision_03.jpghttp://3.bp.blogspot.com/-WxJxEWb6kog/UGyUKDim_3I/AAAAAAAAAhk/tIFW7IKLdHg/s1600/arrows_03.jpghttp://2.bp.blogspot.com/-_9v1CN97nDg/UGyS39rrvrI/AAAAAAAAAhc/Hp_-6eIbRIg/s1600/process_03.jpghttp://3.bp.blogspot.com/-Yid4V_bSR_c/UGyRqbo5VJI/AAAAAAAAAhU/whLrCtdgJ64/s1600/output-input_03.jpghttp://3.bp.blogspot.com/-b6TQd1_QrPw/UGyQt8YViLI/AAAAAAAAAhM/eYSjwtZ_rsI/s1600/terminal+start.jpghttp://3.bp.blogspot.com/-lF6ruaOQHC0/UGyWTq_1EXI/AAAAAAAAAh0/A48lWRxi5Q8/s1600/connector_03.jpghttp://3.bp.blogspot.com/-Ffd5jluyK8Y/UGyVcmhsL5I/AAAAAAAAAhs/YM9BE4o_898/s1600/decision_03.jpghttp://3.bp.blogspot.com/-WxJxEWb6kog/UGyUKDim_3I/AAAAAAAAAhk/tIFW7IKLdHg/s1600/arrows_03.jpghttp://2.bp.blogspot.com/-_9v1CN97nDg/UGyS39rrvrI/AAAAAAAAAhc/Hp_-6eIbRIg/s1600/process_03.jpghttp://3.bp.blogspot.com/-Yid4V_bSR_c/UGyRqbo5VJI/AAAAAAAAAhU/whLrCtdgJ64/s1600/output-input_03.jpghttp://3.bp.blogspot.com/-b6TQd1_QrPw/UGyQt8YViLI/AAAAAAAAAhM/eYSjwtZ_rsI/s1600/terminal+start.jpghttp://3.bp.blogspot.com/-lF6ruaOQHC0/UGyWTq_1EXI/AAAAAAAAAh0/A48lWRxi5Q8/s1600/connector_03.jpghttp://3.bp.blogspot.com/-Ffd5jluyK8Y/UGyVcmhsL5I/AAAAAAAAAhs/YM9BE4o_898/s1600/decision_03.jpghttp://3.bp.blogspot.com/-WxJxEWb6kog/UGyUKDim_3I/AAAAAAAAAhk/tIFW7IKLdHg/s1600/arrows_03.jpghttp://2.bp.blogspot.com/-_9v1CN97nDg/UGyS39rrvrI/AAAAAAAAAhc/Hp_-6eIbRIg/s1600/process_03.jpghttp://3.bp.blogspot.com/-Yid4V_bSR_c/UGyRqbo5VJI/AAAAAAAAAhU/whLrCtdgJ64/s1600/output-input_03.jpghttp://3.bp.blogspot.com/-b6TQd1_QrPw/UGyQt8YViLI/AAAAAAAAAhM/eYSjwtZ_rsI/s1600/terminal+start.jpghttp://3.bp.blogspot.com/-lF6ruaOQHC0/UGyWTq_1EXI/AAAAAAAAAh0/A48lWRxi5Q8/s1600/connector_03.jpghttp://3.bp.blogspot.com/-Ffd5jluyK8Y/UGyVcmhsL5I/AAAAAAAAAhs/YM9BE4o_898/s1600/decision_03.jpghttp://3.bp.blogspot.com/-WxJxEWb6kog/UGyUKDim_3I/AAAAAAAAAhk/tIFW7IKLdHg/s1600/arrows_03.jpghttp://2.bp.blogspot.com/-_9v1CN97nDg/UGyS39rrvrI/AAAAAAAAAhc/Hp_-6eIbRIg/s1600/process_03.jpghttp://3.bp.blogspot.com/-Yid4V_bSR_c/UGyRqbo5VJI/AAAAAAAAAhU/whLrCtdgJ64/s1600/output-input_03.jpghttp://3.bp.blogspot.com/-b6TQd1_QrPw/UGyQt8YViLI/AAAAAAAAAhM/eYSjwtZ_rsI/s1600/terminal+start.jpghttp://3.bp.blogspot.com/-lF6ruaOQHC0/UGyWTq_1EXI/AAAAAAAAAh0/A48lWRxi5Q8/s1600/connector_03.jpghttp://3.bp.blogspot.com/-Ffd5jluyK8Y/UGyVcmhsL5I/AAAAAAAAAhs/YM9BE4o_898/s1600/decision_03.jpghttp://3.bp.blogspot.com/-WxJxEWb6kog/UGyUKDim_3I/AAAAAAAAAhk/tIFW7IKLdHg/s1600/arrows_03.jpghttp://2.bp.blogspot.com/-_9v1CN97nDg/UGyS39rrvrI/AAAAAAAAAhc/Hp_-6eIbRIg/s1600/process_03.jpghttp://3.bp.blogspot.com/-Yid4V_bSR_c/UGyRqbo5VJI/AAAAAAAAAhU/whLrCtdgJ64/s1600/output-input_03.jpghttp://3.bp.blogspot.com/-b6TQd1_QrPw/UGyQt8YViLI/AAAAAAAAAhM/eYSjwtZ_rsI/s1600/terminal+start.jpg8/13/2019 Engineering CP unit I
35/41
C ProgrammingLecture NotesUnit 1
Page 35 of 41
Sample Flowcharts
8/13/2019 Engineering CP unit I
36/41
C ProgrammingLecture NotesUnit 1
Page 36 of 41
1.6. PROCEDURAL PROGRAMMING
structured programming
a programming technique that splits the program into smaller segments(modules) to decrease program development time
decrease program maintenance cost
improve the quality of software
structured programming achieves these goals by using top-downdesign and use of modules
use of limited control structures (sequence, selection and repetition)
management control
Modular ProgrammingModular programming (also called "top-down design" and "stepwise refinement") is a software
design technique that emphasizes separating the functionality of a program into independent,
interchangeable modules, such that each contains everything necessary to execute only one
aspect of the desired functionality.
Conceptually, modules represent a separation of concerns, and improve maintainability by
enforcing logical boundaries between components. Modules are typically incorporated into the
program through interfaces.
Compiler
A compiler is a piece of code that translates the high level language into machine
language. When a user writes a code in a high level language such as Java and wants it to
execute, a specific compiler which is designed for Java is used before it will be executed.
The compiler scans the entire program first and then translates it into machine code
which will be executed by the computer processor and the corresponding tasks will be
performed.
8/13/2019 Engineering CP unit I
37/41
C ProgrammingLecture NotesUnit 1
Page 37 of 41
Shown in the figure is basic outline of the compilation process, here program written in
higher level language is known as source program and the converted one is called object
program.
Interpreter
Interpreters are not much different than compilers. They also convert the high level
language into machine readable binary equivalents. Each time when an interpreter gets ahigh level language code to be executed, it converts the code into an intermediate code
before converting it into the machine code. Each part of the code is interpreted and then
execute separately in a sequence and an error is found in a part of the code it will stop the
interpretation of the code without translating the next set of the codes.
Outlining the basic working of the interpreter the above figure shows that first a source
code is converted to an intermediate form and then that is executed by the interpreter.
The main differences between compiler and interpreter are listed below:
The interpreter takes one statement then translates it and executes it and then takesanother statement. While the compiler translates the entire program in one go and then
executes it.
Compiler generates the error report after the translation of the entire page while an
interpreter will stop the translation after it gets the first error.
8/13/2019 Engineering CP unit I
38/41
C ProgrammingLecture NotesUnit 1
Page 38 of 41
Compiler takes a larger amount of time in analyzing and processing the high level
language code comparatively interpreter takes lesser time in the same process.
Besides the processing and analyzing time the overall execution time of a code is
faster for compiler relative to the interpreter.
PROGRAM EXECUTION:
Step By Step Execution Of C Program
Step 1 : Edit
1. This is First Step i.e Creating and Editing Program.
2. First Write C Program using Text Editor , such as [ TurboC]
3. Save Program by using [.C] Extension.
4. File Saved with [.C] extension is called Source Program.
Step 2 : Compiling
1. Compiling C Program : C Source code with [.C] Extension is given as input to compiler and
compiler convert it into Equivalent Machine Instruction.
2. In Borland C/C++ 3.0 program can be compiled using key [Alt + F9 ].
3. Compiler Checks for errors. If source code is error-free then Code is converted into Object
File [.Obj ].
Step 3 : Checking Errors
1. During Compilation Compiler will check for error, If compiler finds any error then it will
report it.
2. User have to re-edit the program.
3. After re-editing program , Compiler again check for any error.
4. If program is error-free then program is linked with appropriate libraries.
Step 4 : Linking Libraries
1. Program is linked with included header files.
2. Program is linked with other libraries.
3. This process is executed by Linker.
Step 5 : Error Checking
1. If run time error occurs then Run-time errors are reported to user.
2. Again programmer have to review codeand check for the solution.
8/13/2019 Engineering CP unit I
39/41
C ProgrammingLecture NotesUnit 1
Page 39 of 41
Program execution steps
8/13/2019 Engineering CP unit I
40/41
C ProgrammingLecture NotesUnit 1
Page 40 of 41
Program compilation:
Compilation refers to the processing of Source code files(.c,.cc,.cpp) and the creation of an
object file.The compiler merely produces the machine language instructions that corresponds to
the source code file that was compiled.
The C Compilation Model:
The Preprocessor
The Preprocessor accepts source code as input and is responsible for
removing comments
interpreting special preprocessor dir ectivesdenoted by #.
For example
#include -- includes contents of a named file. Files usually called headerfiles. e.g
8/13/2019 Engineering CP unit I
41/41
C ProgrammingLecture NotesUnit 1
o #include -- standard library maths file.
o #include -- standard library I/O file
C Compiler
The C compiler translates source to assembly code. The source code is received from the
preprocessor.
Assembler
The assembler creates object code. On a UNIX system you may see files with a .o suffix (.OBJ
on MSDOS) to indicate object code files.
Link Editor
If a source file references library functions or functions defined in other source files the l inkeditorcombines these functions (with main()) to create an executable file. External Variable
references resolved here also.
COMPARISION OF TESTING & DEBUGGING:
TESTING DEBUGGING
Program testing is the process
of checking program, to verifythat it satisfies its
requirements and to detect
errors.
Debugging is a methodical
process of finding andreducing the number of bugs
in a computer program making
it behave as expected.
Testing include necessarysteps to detect all possible
errors in the program.
One simple way to find thelocation of the error is to use
print statement to display the
values of the variables.
Testing is conducted by thetesters in testing phase.
Debugging done in thedevelopment phase by the
developers.
In testing phase tester will
finds the bug (i.e)called
testing to improve the quality
of the product
in development phase
developer fixes the bug
(i.e)called debugging
Finding and locating of defect. Fixing the defect.
Intension behind to find as
many defect as possible.
Intension is to remove those
defects.