2nd Chapter
2nd Chapter
PSEUDOCODE
Pseudocode is an English-like way of representing the solution to a problem. The prefix
pseudo means fake; Pseudocode, therefore literally means fake code—that is, not the
code that is actually entered into the computer. When using Pseudo code to plan a
program, you can concentrate on the logic and not worry about the rules of a specific
language. It is also easy to change Pseudocode if discover a mistake in logic.
Pseudocode instruction can be considered as midway between English and high-level
languages but free from ambiguities of English language.
FLOWCHART SYMBOLS
Flowchart is a pictorial representation of logic used in a computer program. It illustrates
the major program elements and how they are logically integrated. The flowchart uses
arrows to represent the direction of the program flow and shapes to display actions. The
American National Standard Institute (ANSI) has established standard for the symbols
used in flowchart.
SYMBOLS
Terminal Symbol: (Oval)
The terminal symbol is used to indicate the beginning (START), ending (STOP) and
pauses (HALT) in the program logic flow.
Start Stop Halt
A process symbol is used for all arithmetic and data transfer (MOVE) operations.
Avg= Sum/3
Flowlines: (Arrows)
:
Flowlines with arrowheads are used to indicate the flow of operation, that is, the exact
sequence in which the instructions are to be executed.
The decision symbol is used at point where decision has to be made. It has two arrows
coming out of it usually from bottom or right point with one corresponding to yes and
other corresponding to no. the arrows should always be labelled.
Yes
If A>B
No
If a flowchart becomes very long, the flow lines start crossing at many places that
causes confusion and reduces understandability of the flowchart. In this situation it is
useful to utilize the connector symbol as a substitute for flow lines. An on-page
connector symbol is represented by a circle and a letter or digit is placed within the
circle to indicate the link.
Annotation Symbol:
It is used to add comments, explanatory notes, or clarifications; connected by dashed
line to the symbol being commented on.
CATEGORIES OF FLOWCHARTS
FLOWCHART
System Flowchart:
System flowchart shows the flow of data through an entire computer system.
CONTROL STRUCTURES
Control structure control how the program executes. The following three types of logic,
or flow of control are considered the basic building blocks of all program construction.
Sequence logic
Selection logic
Iteration logic
Sequence
The sequence control structure is the most straightforward: One module simply follows
another in sequence.
.
.
Module 1 Module 1
Module 2
. Module 2
.
Example:
Selection
The selection control structure employs a number of conditions which lead to a selection
of one out of several alternative modules. The structures which implement this logic are
called conditional structures or IF structures. The end of IF structure is frequently
indicated by the statement “[End of IF structure]” or some equivalent statement.
This control structure has two forms: IF and IF-ELSE.
The IF selection structure either performs an action if the condition is true or skips
the action if the condition is false. It is less complicated.
IF condition then
[Module A]
[End of IF structure] Yes
Test
Condition?
No
Module 1
IF-ELSE selection structure performs an action if the condition is true and perform a
different action if the condition is false. It is more complicated than IF.
IF condition then
[Module A]
ELSE Yes
[Module B] Test
Condition? Module 1
[End of IF structure]
No
Module 2
Iteration
Iteration is often referred to as a loop, because the program will keep repeating the
activity until the condition becomes false. Loops simplify programming because they
enable the programmer to specify certain instructions only once to have the computer
execute them many times. WHILE, DO-WHILE, and FOR are three types of structures
involved in loops. Each type begins with a Repeat statement and is followed by a
module, called the body of the loop. The statement “(End of loop)” or some equivalent
statement frequently indicates the end of structure.
TYPES OF FLOWCHART
There are four main types of flowchart, which can be combined in different ways to
represent any given problem are given below.
Sequential Flowchart: This is the simplest type of flowchart involving no decisions,
branches or loops.
Branch (or Jump) Flowchart: In this type, one or more decision boxes are introduced,
and the action taken depends upon whether the result of the decision is yes or no.
Loop Flowchart: A loop represents a procedure which may be repeated a definite or
indefinite number of times.
Nested Loops in a Flowchart: nested loops in flowcharts are represented by loops
within loops.
ADVANTAGES OF FLOWCHART:
Communication: Flowcharts are better way of communicating the logic of a system to
all concerned or involved.
Effective analysis: With the help of flowchart, problem can be analyzed in more
effective way
Efficient Coding: The flowcharts act as a guide during the systems analysis and
program development phase.
Proper Debugging: The flowchart helps in debugging process.
DISADVANTAGES OF FLOWCHART:
Complex logic: Sometimes, the program logic is quite complicated. In that case,
flowchart becomes complex and clumsy. This will become a pain for the user.
Alterations and Modifications: If alterations are required the flowchart may require re-
drawing completely.