WK3 Lesson2
WK3 Lesson2
Presentation by
MANZA JOSHUA KIILU
OBJECTIVES
By the end of the lesson the trainee should
be able to:
A)Describe structured programming design
concepts
B)Describe program design tools
ALGORITHMS
FLOWCHARTS
PSEUDOCODE
MANZA JOSHUA
3 GROUP PRESENTATIONS ON
PROGRAMMING APPROACHES
GROUP 1
Discuss on TOP-DOWN approach
GROUP2
Discuss on BOTTOM UP approach
GROUP3
Discuss on DATA DRIVEN approach
N/B Each to present for 10 minutes
MR MANZA 02/05/2025
4 PROGRAM DEVELOPMENT TOOLS
DEVELOPMENT OF ALGORITHMS
After carefully analyzing the requirements specification, the
programmer usually comes up with the algorithm.
An Algorithm is a limited number of logical steps that a program follows in order to
solve a problem.
A step-by-step (a set of) instructions which when followed will produce a solution to a
given problem.
Algorithms take little or no account of the programming language.
They must be precise/ accurate, unambiguous/clear and should guarantee a solution.
MANZA JOSHUA
02/05/2025
Algorithms can be illustrated
using the following tools:
Pseudo codes.
Flowcharts.
Decision Tables.
Decision Trees.
PSEUDOCODES
Pseudocode : are structured English-like phrases that indicate the
program steps to be followed to solve a given problem.
Guidelines for designing a good pseudocode.
The statements must be short, clear and readable.
The statements must not have more than one meaning
The pseudocode lines should be clearly outlined and indented.
A pseudocode must have a Begin and an end.
The input, output and processing statements should be clearly
stated using keywords such as PRINT, READ, INPUT, etc.
MANZA JSOHUA
Example 1:
Write a pseudocode that can be used to prompt the user to enter
two numbers, calculate the sum and average of the two numbers
and then display the output on the screen.
START
PRINT “Enter two numbers”
INPUT X, Y
Sum = X + Y
Average = Sum/2
PRINT Sum
PRINT Average
STOP
MANZA JOSHUA
Example 2:
Write a structured algorithm that would prompt the user to enter the
Length and Width of a rectangle, calculate the Area, then display the
result.
Solution
5 minutes
Class assignment
Write a pseudocode to
calculate volume of a sphere
FLOWCHARTS
A Flowchart is a chart that demonstrates the logical sequence of events
that must be performed to solve a problem.
Types of Flowcharts.
System flowchart. This is a graphical model that illustrates
(in summary) the sequence of events in a system, showing
the department or function responsible for each event.
Program flowchart. This is a diagram that describes, in
sequence, all the operations required to process data in a
computer program
PROGRAM FLOWCHARTS.
A Flowchart is constructed using a set of special
shapes (or symbols) that have specific meaning.
Symbols are used to represent operations, or data flow
on a flowchart.
The words Begin & End (or Start & Stop) should be inserted in the Terminal symbol
Input or Output symbol.
(Parallelogram)
For example;
(Rectangle)
- Process symbol is used to indicate that a processing or data transformation is taking place.
The information placed within the process symbol may be an algebraic formula or a sentence
to describe processing.
4. Decision symbol.
NO (Rhombus)
YES
5. Flow lines.
Flow lines with arrowheads are used to indicate the direction of processing of the program
logic, i.e., they show the order in which the instructions are to be executed.
The normal flow of a flowchart is from Top to Bottom, and Left to Right.
Note. Flow lines should never cross each other.
CONNECTOR
6. Connector symbol.
Sometimes, a flowchart becomes too long to fit in a single page, such that the flow lines start
crisscrossing at many places causing confusion & also making the flowchart difficult to
understand.
The Connector symbol is used as a connecting point for arrows coming from different
directions.
General guidelines for drawing a program flowchart.
A flowchart should have only one entry/starting point and one exit point (i.e., ensure that the
flowchart has a logical start and finish).
The flowchart should be clear, neat and easy to follow.
Use the correct symbol at each stage in the flowchart.
The flowchart should not be open to more than one interpretation.
Avoid overlapping the lines used to show the flow of logic as this can create confusion in the
flowchart.
Make comparison instructions simple, i.e., capable of YES/NO answers.
The logical flow should be clearly shown using arrows.
Note. A flowchart should flow from the Top to Bottom of a page, and from the Left to the
Right.
Where necessary, use Connectors to reduce the number of flow lines.
Connectors are helpful when a flowchart is several pages long, and where several loops are
needed in the logic of the flowchart.
Check to ensure that the flowchart is logically correct & complete.
Discuss advantages and
disadvantages of flowcharts
(In Groups of threes)
3 minutes
Example 1:
Draw a flowchart for a program that can be used to prompt the user to enter two numbers, find
the sum and average of the two numbers and then display the output on the screen.
Start
X, Y
Sum = X + Y
Average = Sum/2
Stop
Example 2:
Draw a flowchart for a program that would prompt the user to enter the Length and Width of a
rectangle, calculate the Area and Perimeter, then display the result.
Start
L, W
Area = L x W
Perimeter = 2 (L x W)
Stop
Class assignment
QUESTION1
Draw a flowchart for a program that can be used to calculate the Diameter,
Circumference and Area of a circle and then display the output on the screen .
QUESTION2
Design a flowchart for a program that can be used to classify people according to
age. If a person is more than 20 years; output “Adult” else output “Young
person”.
QUESTION3
Draw a flowchart for a program that would be used to classify animals according
to sex. If a letter M is input, the program should display ‘Male’ otherwise it
should display “Female”.
GROUP WORK ASSIGNMENT