Download as ppt, pdf, or txt
Download as ppt, pdf, or txt
You are on page 1of 29

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

 Most real life problems require some kind of


decision making to take a certain course of
action. This means that instruction or a whole
block of instructions can be executed,
repeated or skipped.
Output
 The processed data which produced
certain result is known as the output.
 The output data will be presented in a sheet
of paper through the printer or display on a
monitor.
Identifying steps in programming

1. Defining and analyzing problems


2. Planning of variables
3. Drawing of flowchart
4. Program writing
5. Testing and debugging program
6. Documentation of program.
Identifying steps in programming
 Process of designing program can be divided
into two phases mainly the problem solving
phase and implementation phase.
 The problem solving phase consist of steps 1
through 3
 Implementation phase involved steps 4 and 5.
 While in step 6, documentation is done
throughout the process of designing program.
Defining and analyzing problems
 Programming begin with a specification
of problems.
 This steps is to identify and understand
what are the problems to resolve.
 The problems must be clearly define,
explicit and the requirements in
resolving it.
Planning of variables
 Variables are simply references to memory
locations.
 A well plan use of variables will produce an
efficient execution of program in terms of
speed and memory utilization.
Drawing of Flowchart

 Flowchart represents algorithm in graphic form


comprising of geometrical symbols which is
interrelated by line of flow.
Drawing of Flowchart
Start

Read price value


input

Calculate discount value = price * discount


rate process

Price of item after discount = price -


discount value process

Display price after discount


output

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 :

i. An accurate specification of requirement


ii. Detail input, output, constraint and formula
for the above problems
iii. Algorithm in the form of flowchart or
pseudocode
iv. Program source complete with comment
v. Sample program which had been run and
executed and the tested data.
vi. Guideline on how to use the program.
End of unit 1

You might also like