Professional Documents
Culture Documents
Programming Principles and Techniques - Session 3
Programming Principles and Techniques - Session 3
rA
pt
ec
h
C
en
tre
U
se
O
nl
y
y
nl
O
Explain algorithm
se
Explain flowcharts
U
Explain pseudocodes
tre
en
C
h
ec
pt
rA
Fo
y
nl
O
The programmer has to plan and write down
se
the solution to a problem in a particular
U
manner and this is known as algorithm.
tre
en
The two tools used by the programmer are
C
h
flowchart and pseudocode.
ec
pt
rA
Fo
y
nl
O
Algorithm is an ordered set of instructions.
se
U
The algorithm should have the ability to alter the
tre
order of execution of the instructions.
en
C
The three types of statement constructs that an
h
algorithm can have are as follows:
ec
Sequential
pt
Conditional
rA
Iteration
Fo
y
nl
O
A flowchart is a graphical representation of an
algorithm.
se
U
It charts the logical flow of instructions or
tre
activities in a process.
en
C
Flowcharts help programmers to view how the
h
statements in a program are interrelated.
ec
pt
rA
se
and displaying the sum of the two numbers using a third
variable. The flowchart for this example is shown in the
U
figure.
tre
en
C
h
ec
pt
rA
Fo
y
nl
O
Some of the essential points to be considered while
drawing a flowchart are as follows:
se
Initially concentrate on the logic of the problem and draw
U
out the main path of the flowchart
tre
Maintain consistent level of detail for a flowchart
Must not contain minute details. Only the essential and
en
meaningful steps need to be represented
C
Common and easy to understand words should be used
h
Consistent usage of variable names
ec
Should be simple
Fo
y
nl
O
Some of the advantages of using flowcharts
se
are as follows:
U
Easy to understand
tre
Effective analysis of problem
en
Effective joining of different parts
Ease in coding
C
h
ec
Systematic debugging
pt
Systematic testing
rA
Fo
y
nl
O
Besides the advantages, flowcharts have some
se
disadvantages. They are as follows:
U
Time consuming
tre
Difficult to change
en
No standards
C
h
ec
pt
rA
Fo
y
nl
O
The best practices for drawing flowcharts are as
se
follows:
U
The direction of the arrow flow should be to one side
tre
either from top to bottom or from left to right.
Standard symbols must be used in a flowchart so that
en
it can be understood by all.
C
All the symbols in a flowchart must be named
h
appropriately.
ec
consistent.
Fo
y
nl
O
The word pseudo means false. As the name
se
suggest, pseudocode is not the actual code.
U
tre
It is a method of algorithm writing which uses
en
a certain standard set of words which makes it
resemble a code.C
h
ec
pt
executed as a code.
Fo
y
nl
O
Each pseudocode must start with the word BEGIN or
START, and end with END or STOP.
se
U
The statements between START and END are English
tre
phrases and indented to make the word START and
en
END stand out.
C
To display some value, the word DISPLAY, WRITE, or
h
ec
PRINT is used.
pt
READ is used.
Fo
y
nl
O
The pseudocode shows the process to store the sum of variables in
a third variable, and then display the value stored in this third
se
variable as shown in the example.
U
BEGIN
tre
INPUT A, B
en
C = A + B
DISPLAY C
END C
h
ec
se
pseudocodes are as follows:
U
The pseudocode must be easy to understand by
tre
all and not just the programmer. The variables
en
mentioned in the pseudocode must be self-
C
descriptive. Avoid using abbreviations and
h
shortened versions of words in the pseudocode.
ec
se
are as follows:
U
Easy to create
tre
No symbols
en
No specific syntax
C
Easy to translate
h
ec
Reduces time
pt
rA
Fo
y
nl
O
Besides the advantages, pseudocodes have
se
some disadvantages. They are as follows:
U
Lack of standards
tre
Do not focus on big picture
en
C
h
ec
pt
rA
Fo
y
nl
O
The best practices for writing pseudocodes are as
follows:
se
The vocabulary used to write a pseudocode must be
U
simple to understand and should be on the lines of
tre
structured programming.
Each statement in the pseudocode must be written in a
en
separate line.
C
The keywords, procedure names, and module names must
be capitalized in pseudocode.
h
ec
hierarchy.
y
nl
An algorithm can be defined as a procedure, formula, or recipe for
O
solving a problem.
se
A flowchart is a graphical representation of an algorithm. It charts
the flow of instructions or activities in a process. Each activity in a
U
flowchart is depicted using symbols.
tre
A flowchart begins with the START or BEGIN keyword, and ends
with the END and STOP keyword.
en
The DISPLAY keyword is used to display some value to the user in a
flowchart.
C
Pseudocode is not actual code. It is a method of algorithm writing
h
which uses a certain standard set of words which makes it resemble
ec
a code.
pt
Each pseudocode must start with the word BEGIN or START, and
rA
pseudocode.