CFP - Chapter 2
CFP - Chapter 2
2
SCHOOL ACTIVITY 1: PSEUDOCODE (COMPUTATIONS)
TAKE HOME ACTIVITY 1: PSEUDOCODE (QUIZZES)
TAKE HOME ACTIVITY 2: PSEUDOCODE (GREATER AND
SMALLER NUMBER)
2.2 FLOWCHART AND FLOWCHARTING SYMBOLS
2.2.1 TYPES OF FLOWCHARTS
SAMPLE PROBLEMS
SCHOOL ACTIVITY 2: FLOWCHART (COMPUTATIONS)
TAKE HOME ACTIVITY 3: FLOWCHART (QUIZZES)
TAKE HOME ACTIVITY 4: FLOWCHART (THREE NUMBERS)
TAKE HOME ACTIVITY 5: FLOWCHART SYMBOLS
2.0 OBJECTIVES
Students, after studying this you will be able to explain
Program and Logic Formulation. The main features of this chapter
are as follows;
o Learn to familiarize flowchart symbols
o Learn to construct an algorithm
o Learn to write a pseudo-code
o Develop a program using flowchart, algorithms and pseudo-
codes
Topics
• Algorithms
• Pseudocode
• Flowcharts
Introduction to Algorithms
1. A sequence of instructions.
2. A procedure or formula for solving a problem.
3. It was created mathematician, Mohammed ibn-Musa al-
Khwarizmi.
4. Often used for calculation, data processing and
programming.
5. Algorithms can be expressed in any language.
ALGORITHMS PROCEDURES
Introduction to Algorithms
• Two forms of Algorithm:
– Pseudocode
– Flow chart
2.1.1 PSEUDOCODE
• Pseudocode is a counterfeit code, because it’s not really
programming code since it specifies only the steps required to
accomplish the required task.
• You must break the main tasks that must be accomplished into
smaller ones in order to be able to eventually write fully
developed code since it is easier to understand the concept.
IF (condition) THEN
some action
ELSE
alternative action to take
ENDIF
Visibility of variables
PSEUDOCODE EXAMPLES
Example 1:
Program Specification:
PSEUDOCODE:
Start
Initialize all the needed variables.
Prompt the user to enter the first integer
Prompt the user to enter a second integer
Compute the sum of the two user inputs
Display an output prompt that explains the answer as the
sum Display the result
Stop
Example 2:
Write a pseudocode that will find the average of any three
numbers.
PSEUDOCODE:
Start
Initialize all the needed variables.
Read values of num1, num2, sum
Compute for sum of three numbers (Sum = num1 + num2 + num3)
Compute for average of three numbers (Average = sum / 3)
Write value of average
Stop
Example 3:
PSEUDOCODE:
Start
Initialize all the needed variables.
Read value of a Number.
Compute for the value of Square (Square = Number * Number)
Compute for the value of a cube (Cube = Square * Number)
Write values of Square and Cube.
Stop
Example 4:
Write a pseudocode that will find the biggest of two numbers.
PSEUDOCODE:
Start
Initialize all needed variables.
Read num1 and num2.
If num1 > num2,
then BIG = num1
Else
BIG = num2.
Write BIG
Stop
Example 5:
Write a pseudocode that will calculate pay of a worker.
PSEUDOCODE:
Start
Initialize all needed variables.
Input numbers of hours obtained by a worker.
Input rate of a worker.
Compute for pay of a worker (Pay = hours * rate)
Print pay of a worker.
End
Name: Date:
Section/Schedule: Instructor:
✓
Developers need to promote and implement understanding of a
process by explaining the steps pictorially. Developer may
have differing ideas about how a process works and a
Flowchart can help you gain arrangement about the sequence of
steps to be followed. Flowcharts promote understanding in a
way that written procedures cannot do. One good Flowchart can
replace pages of words normally.
✓
Using flowchart, it provides a tool for training users
because of the way they visually lay out the sequence of
process steps. Flowcharts can be very helpful in training
users to perform the process according to standardized
procedures that needs to follow.
✓
Flowchart can identify problem areas and opportunities for
process improvement. Once you break down the process steps
and draw a diagram, problem areas become more visible and you
can draw solutions easily. It is easy to spot opportunities
for simplifying and refining your process by analyzing
DOCUMENT SYMBOL
A printed document or report.
DECISION SYMBOL
A decision or branching point. Lines
representing different decisions emerge
from different points of the diamond.
INPUT/OUTPUT SYMBOL
PREPARATION SYMBOL
Represents a set-up to another step in
the process.
SUBROUTINE SYMBOL
Indicates a sequence of actions that
perform a specific task embedded within
a larger process. This sequence of
actions could be described in more
detail on a separate flowchart.
✓
Identify the right people to develop the chart for fast access.
✓
Determine what you expect to get from the Flowchart before start.
✓
Identify who will use it and how it will used.
✓
Define the level of detail you need for specific purposes.
✓
Establish the boundaries of the process for rooms of improvement.
✓
Start with the big picture. It is best to draw a macro-
level Flowchart first. After you’ve depicted this big
picture of the process, you can develop other diagrams with
increased levels of detail.
✓
Observe the current process. A good way to start Flowcharting
a process is to walk through the current process, observing it
in actual operation.
✓
Record the process steps you observed. Record the steps as
they actually occur in the process as it is. Write the
steps on index cards or post it notes. You can use a
different color to represent each individual or group TM
involved if that will help you to understand and depict the
flow more accurately.
✓
Arrange the sequence of steps. Now arrange the cards or
post-it notes TM exactly as you observed the steps. Using
cards lets you rearrange the steps without erasing and
redrawing and prevents ideas from being discarded simply
because it’s too much work to redraw the diagram.
Interpretation Steps
Step 1 - Examine each process step.
Bottlenecks? Weak links? Poorly defined steps? Cost-added-
only steps?
Example 1:
Program Specification:
Draw a flowchart that obtains two integer numbers from the user.
It will print out the sum of those numbers (see pseudocode
below).
PSEUDOCODE:
Start
Initialize all the needed variables.
Prompt the user to enter the first integer
Prompt the user to enter a second integer
Compute the sum of the two user inputs
Display an output prompt that explains the answer as the
sum Display the result
Stop
FLOWCHART
PSEUDOCODE:
Start
Initialize all the needed variables.
Read values of num1, num2, sum
Compute for sum of three numbers (Sum = num1 + num2 + num3)
Compute for average of three numbers (Average = sum / 3)
Write value of average
Stop
FLOWCHART
PSEUDOCODE:
Start
Initialize all the needed variables.
Read value of a Number.
Compute for the value of Square (Square = Number * Number)
Compute for the value of a cube (Cube = Square * Number)
Write values of Square and Cube. Stop
FLOWCHART
PSEUDOCODE:
Start
Initialize all needed variables.
Read num1 and num2.
If num1 > num2,
then BIG = num1
Else
BIG = num2.
Write BIG
Stop
FLOWCHART
PSEUDOCODE:
Start
Initialize all needed variables.
Input numbers of hours obtained by a worker.
Input rate of a worker.
Compute for pay of a worker (Pay = hours * rate)
Print pay of a worker.
End
FLOWCHART