Algorithm and Flowcharting
Algorithm and Flowcharting
LECTURE: 05-28-2020
Introduction to Computer Programming
Objectives
To relate programming to problem-solving
To develop algorithms in solving problems
To represent algorithms in a flowchart
To discuss the rules and guidelines for drawing flowchart
To discuss the advantages and limitations of using flowcharts
C. Flowcharting
Flowchart is a diagram representing the logical sequence which is a combination of steps or operations to be performed. It
consists of labeled geometrical symbols that are interconnected to provide a pictorial representation of a data processing
procedure. A flowchart is simply a visual representation of an algorithm. It is the blueprint of the program.
Advantages:
1. Flowcharts are language independent
2. It enforces users to give attention to significant matters over the less significant ones.
3. Flowcharts provide an alternative to usual narrative description
4. Flowcharts are easier to understand
Limitations:
1. Flowcharts do not represent a programming language
2. Thinking in graphic terms is not normal
3. Certain details often require a long sequence of interconnected symbols
4. It does not convey why a given set of operations is made.
5. It does not highlight the important details
RJBO pg. 1
Computer Programming
Flowcharting Symbols
1. Input/Ouput (Parallelogram)- represents an instruction to an input or output device
2. Processing (Rectangle)- used to represent program instructions such as arithmetic operations
3. Decision (Diamond)- denotes a point in the program where more than one path can be taken. Based upon variable
conditions, alternative paths are possible. The particular path chosen depends on the test result.
4. Preparation (Hexagon)- used to represent instructions that will modify a program’s course of execution. It is
commonly used to specify operations such as control, index register, initialization, switch setting and in indicating loops.
5. Terminal (Oval)- designates the beginning and end of a program
6. On- page Connector (Small Circle)- non-processing symbol which is used to connect one part of a flowchart to
another without drawing flow lines. It denotes an entry or exit from another part of the flowchart and also used to
change reading sequence of a flowchart on the same page.
7. Off-page Connector (Small Pentagon)- a connector used to designate entry to or exit from a page when a flowchart
requires more than one page.
8. Flow Direction Indicators (Arrowheads)- used to show the direction of processing or data flow.
9. Flow Lines (Horizontal/Vertical Lines)- used to show reading order or sequence in which flowcharts symbols are to be
read. Flow lines are sometimes drawn with arrowheads.
2 4
1 3 5
6 7
8&9
GUIDELINES IN FLOWCHARTING
1. All operations (tasks) should be listed out in a logical order according to the flow of operations. The flowchart must be
clear, simple and neat, to avoid vagueness and confusion.
2. Declare all variables (or labels/legends) needed in the flowchart and must be written anywhere near the flowchart, but it is
better to write it before the flowchart or at the right side of it. Example. let: num1 = first input number
num2 = second input number
sum = sum of the two input numbers
3. A flowchart must always begin and end with a terminal symbol. There should only be one start and one end for every
flowchart. In addition, a Start must have only flowline coming out and an End/Stop must have only flowline coming in.
4. In using the process symbol, input/output symbol, and the preparation symbol, there should only be one flowline coming
out but it may have one or more flowlines coming in.
5. In using the preparation symbol, you assign numeric values equal to zero(0) while characters(or string) variables equal to”
“(null value). Sometimes, due to many variables to be declared, this symbol will just have Clear to tell that all variables are
initialized.
6. The decision symbol must have two flowlines coming out(one for true and one for false condition) and must have only one
flowline coming in.
7. In using the on-page/off-page connector, it must be going out and in of the symbol. There should be the same label of
connector to show continuity or flow of the flowchart. Note: use on-page when connection is within the same page and use off-
page when you show connection of separate pages.
8. Connectors are better to be used when the flowchart is complex and contains many operations. Using connectors is better
than intersecting flowlines which may give confusion to the reader. Note therefore that intersections should be avoided.
9. The usual direction of the flow of the flowchart is from left to right or from top to bottom.
10. It is good to try assigning values to variables and go through the flowchart to test the validity and correctness of the
flowchart.
11. Use the flowchart appropriately according to its purpose.
Today there are many software that can be used to prepare a flowchart. Software that can be used in preparing flowcharts is
classified as computer-aided software engineering (CASE) tools since it helps in the preparation of an analysis of the
problem. Microsoft Visio and Edraw are some CASE software that can be used. Some may be downloaded free in the
Internet. Microsoft Word can be an alternative software in preparing flowcharts.
RJBO pg. 2
Computer Programming
Problems:
1. Draw a flowchart that computes the area of a rectangle whose dimensions are specified by the user.
START
A
L=0
W=0
Print L,
A= 0
W and A
Read L
and W END
A=L*W
2. The radius of a circle is equal to one unit. Draw a flowchart to compute the corresponding area of the circle and print
out the value of the radius and the area.
3. Given three numbers A, B, C. Draw a flowchart to compute and print out the sum, average and the product of these
values.
4. The ABC Manufacturing Company plans to give a year-end bonus to each of its employees. Draw a flowchart which
will compute the bonus of an employee. Consider the following criteria: If the employee’s monthly salary is less than
10,000, the bonus is 50% of the salary; for employees with salaries greater than 10,000, the bonus is 10,000. Print out
the name and corresponding bonus of the employee
5. Given two numbers, X and Y. Draw a flowchart that determines the higher number. Print out the higher number.
6. Given two numbers X and Y. Draw a flowchart to determine the difference between X and Y. If X-Y is negative,
compute R=X+Y; if X-Y is zero, compute R=2X+2Y; and if X-Y is positive, compute R=X*Y. Print out the values of
X, Y and R.
7. A metric ton is 35,273.92 ounces. Draw a flowchart that will read the weight of a package in ounces and outputs the
weight in metric tons. It should allow the user to repeat this calculation as often as the user wishes.
8. The volume of a rectangular box is given by the formula:
Volume = Length*Width*Height
Draw a flowchart to calculate the volume of a box whose dimensions are specified by the user. Print out the
volume and the dimensions.
9. The volume of a sphere is given by the formula:
Volume = 4/3*Pi*R3
Draw a flowchart to calculate the volume of a sphere with the radius given by the user. Print out the volume
and the radius.
10. Given a number. Draw a flowchart that determines if the number is positive or negative. Print out the number
which is either positive or negative
RJBO pg. 3