IT 101 Module 2.0 2022
IT 101 Module 2.0 2022
SUBJECT : IT 101
MODULE 2
TITLE: Algorithms and Flowcharts
OVERVIEW
This module teaches the basics of algorithms and flowcharts. It explains what is an algorithm and what is
flowchart and how are they relate with each other. It also introduces us on how to use the different flowcharting
symbols and embeds variables and logical operator in them. It also teaches us the different flowcharting
structures and distinguish non-structured flowcharting to structured flowcharting and converts unstructured
flowchart (like spaghetti code) to structured one.
OBJECTIVES
At the end of this module, the students are expected to:
DISCUSSION
Example:
1. Considering you’re going to use a rice cooker and that the utensils are all clean, make an algorithm and a
flowchart that depicts on how to cook rice from the moment you prepare the ingredients until it is
cooked.
Solution:
Algorithm
1. Put some measured rice into the rice cooker
2. Put also some water into it
3. Cleanse the rice
4. Drain it
5. Put some measured water into it
6. Plug the wire
7. Push the button to cook
8. Wait until it is cooked
9. Unplug the wire
Flowchart
MODULE 2
IT 101 – Introduction to Programming
Flowcharting symbols:
Process ➔ is used to illustrate a process, action or operation.
Input/ Output ➔ shows the inputs and the outputs from a process.
Examples:
1. Considering that A=10 and B=5, make an algorithm and a flowchart that computes and display the sum,
difference, product, quotient and average out of those numbers.
Solution:
MODULE 2
IT 101 – Introduction to Programming
ALGORITHM
a. Initialize A=10, B=5, sum=0, diff=0, prod=0, quo=0 and ave = sum/2
b. Compute sum by adding A+B, diff by subtracting A from B, prod by multiplying A to B, quo by
dividing A to B and ave by dividing sum by two (2)
c. Display the sum, diff, prod, quo and ave.
FLOWCHART
FLOWCHART
3. Make a flowchart that computes the average grade of a student considering that its formula is (average
= (Prelim Grade + Midterm Grade + Semi-Final Grade + Final Grade)/4).
Solution:
MODULE 2
IT 101 – Introduction to Programming
ALGORITHM
1. Initialize variables prelim_grade=0, midterm_grade=0, sf_grade=0, final_grade=0 and
average_grade=0;
2. Put values into prelim_grade, midterm_grade, sf_grade, final_grade
3. Compute the average grade using the formula
average_grade = prelim_grade + midterm_grade + sf_grade + final_grade
FLOWCHART
Structured Flowcharting
Loops and Counters
Loop ➔ is used when it is desired to make the same calculation on more than one set of data.
Counters ➔ is a set up in a program loop to keep track of the number of times the program segment is
repeated.
Ex.:
1. Make a flowchart that continuously asks for a number then display it five (5) times.
Solution:
Select Case
Select Case ➔ is used when there are three (3) or more selections.
Ex.:
1. Make a flowchart that would ask for the age of a person. It will then display the age and remarks of the
person whether he/she is a kid (0 to 10 yrs. old), teen-ager (11 to 19 yrs. old), adult (20 to 59 yrs. old)
and senior citizen (60 above).
Solution:
MODULE 2
IT 101 – Introduction to Programming
Y
N
Y
N
Y
N
Flowcharting Structures
Structures in flowcharting:
1. Sequence
2. Decision
3. Loop
Sequence
Also called “concatenation structure”
In sequence, one program statement follows another.
Ex.
a. Make a flowchart that accepts numbers A and B, computes and display their sum.
Solution:
MODULE 2
IT 101 – Introduction to Programming
Decision
Also called “selection structure”
Occurs when a decision must be made.
Ex.
b. Make a flowchart that accepts number then determine if that number is positive or negative.
Solution:
stop
Loop
Also called “repetition structure”
The loop is a process that is repeated as long as a certain condition remains true.
Ex.
c. Make a flowchart that continuously asks for a number. It will only stop once the number entered is -1.
Solution:
MODULE 2
IT 101 – Introduction to Programming
EVALUATION
REFERENCES
1. Introduction to flowcharting
http://www.tmv.edu.in/pdf/distance_education/bca%20books/bca%20ii%20sem/bca-
222%20%27c%27%20%27programming.pdf
2. Algorithm and Flowchart Manual for Students
http://www.yspuniversity.ac.in/cic/algorithm-manual.pdf