Unit 1
Unit 1
Unit 1
E3062
UNIT 1
Basic Concept and Problem
Solving in Programming
General Objective
To Understand the Concept of
Program Characteristics and Steps
in Developing Program.
Specific Objectives
define what is a program.
explain the meaning of program
structure.
discuss steps in programming
Basic concept of Programming
1. Integrity
2. Clarity
3. Simplicity
4. Efficiency
5. Modularity
6. Generality
Basic concept of Programming
1. Integrity. This refer to the accuracy of the
calculations since it will be meaningless if
calculations are not carried out correctly.
2. Clarity. This refer to the overall readability
of the program, with particular emphasis on
its underlying logic. If a program is clearly
written, it should be possible for
programmer to follow the program logic with
ease.
Basic concept of Programming
3. Simplicity. The clarity and accuracy of a
program are usually enhanced by keeping
things as simple as possible, consistent
with the overall program objectives.
4. Efficiency. This is concerned with
execution speed and efficient memory
utilization.
Basic concept of Programming
5. Modularity. Many programs can be broken
down into a series of identifiable subtask that
enhances accuracy and clarity of a program
and facilitates future program alterations.
6. Generality. Usually we will want a program
to be as general as possible, within
reasonable limits. A considerable amount of
generality can be obtained with very little
additional programming effort.
Definition of program
A set of instructions that tells the
computer what to do is called a
program.
For example, a word processor is a
program written in computer language
like C++, that tells the computer what to
do when you type in a letter.
The components of program
structure
1. Declaration
2. Input
3. Storage
4. Operation
5. Control
6. Output
Declaration
A declarations associates a group of
variables with a specific data type. All
variables must be declared before they can
appear in executable statements.
Example :
int a, b, c;
float root1, root2;
char flag, text[80]
Input
A set of information called data will be
entered into the computer from
keyboard, floppy disk, hard disk etc. and
stored in a portion of the computer
memory.
This input which is an input to the
computer will then be processed to
produced the desired result.
Storage
Every piece of information are stored within
the computer’s memory which is encoded as
some unique combination of zeros and ones.
Small computers have memories that are
organized into 8-bit multiples called bytes.
Computers also employ auxiliary storage e.g.
disks in addition to their primary memories
which allowed information to be stored
permanently and can be physically
disconnected when not in use.
Operation
There are two different ways computer can be
utilized by many different users. These are
batch mode and the interactive mode.
In batch mode of operation the program and
the data are typed into the computer and
stored within computer’s memory and
processed in its proper sequence.
Operation (continue)
Large quantities of information can be
transmitted into and out of the computer
without the user present while the job being
processed. Batch processing can be
undesirable for simple jobs.
In interactive mode the user and the computer
are able to interact with each other during
computational session.
Control
Program control refers to the order of
execution of instructions in a program. The
instruction can be executed sequentially –
one by one, from top downwards or non
sequential execution of program instruction.
End
Program writing
In the design of program it should be written
as simple as possible.
The main objective is to give a clear,
readable programs through an orderly and
disciplined approach to programming.
Testing and debugging program
Once the program has been written it must
be compiled and executed.
executed This is
accomplished by an editor and compiler.
An editor lets us type a program, makes
changes and save it to a file.
The compiler then translates the program into
a form that the computer can read.
Testing and debugging program
Once the program has been compiled and
executed the presence of errors will be
readily apparent.
Syntactic and execution errors usually result
in the generation of error when compiling or
executing a program.
Testing and debugging program
Much more difficult to detect are logical errors
since the output resulting from logically
incorrect program may appear to be error
free.
Thus a good bit of probing may be required
which is known as logical debugging.
Documentation of program
Program must be documented for future
references and maintenance process.
A well documented program will make it
easier for the original programmer or other
programmer to follow the program logic and
design.
Documentation of program
Program document should consist of :