K to 12 Basic Education Curriculum
Technical Vocational Livelihood Education
PROGRAMMING LANGUAGES (CSS 2)
Number of Sessions (Time Allotment): 60 Hours (2nd Quarter)
LOGIC FORMULATION
SUMMARY OF LEARNING OUTCOMES (LO):
➢ LO 01: Programming Cycle
➢ LO 02: Algorithm
➢ LO 03: Pseudocode
➢ LO 04: Flowchart
TANAUAN INSTITUTE, INC.
Senior High School Department
Modified Learning Scheme: Workbook
PROGRAMMING LANGUAGES (CSS 2)
1st Semester, S.Y. 2020-2021
Subject Teacher: LORIE A. AVILLANOZA
Name: ___________________________________ Score: ________________
Section: __________________________________ Date: _________________
Module 05: LOGIC FORMULATION
Topic : Lesson 01: Programming Cycle Session :
Lesson 02: Algorithm WEEK 05
Lesson 03: Pseudocode 4 hrs.
Lesson 04: Flowchart
Objectives of the Lesson :
At the end of the lesson, the student should be able to:
• Identify the steps in creating a program,
• Define algorithm, pseudo code, and flowchart,
• Enumerate the different flowchart symbols used,
• Identify Define and explain what a pseudocode
Values Integration:
Nowadays, PROGRAMMING is already a large part of daily life-from games in gadgets to mainstream movies,
they are anywhere, However, a few decades ago, program is very limited. Programming came a long way before
getting to gadgets, televisions and big screens. Explain problem definition, problem analysis, algorithm, and
coding and debugging.
• Enumerate the guides to a good algorithm
• Define and explain what a pseudocode is
• Enumerate and define the basic flowchart symbols
PROGRAMMING LANGUAGES (CSS 2) / LORIE AVILLANOZA 1
Questions
1. What are the Importance of PROGMMING CYLE?
2. What are the major contributions of ALGORITHM Nowadays?
3. What are some rules that you think must be followed when creating a PSEUDOCODE?
Discussion :
Lesson 01: PROGRAMMING CYCLE
Below are the steps involved in the programming cycle:
• Problem Definition
• Problem Analysis
• Algorithm Development
• Coding and Debugging
Problem definition - specifies what we want the computer to do.
Problem analysis - looking at the problem itself; point of view of the computer; start with
the input/output.
Algorithm development - an outline that breaks problem down into segments; strategy
on how to do the task.
Coding and debugging - the process of removing errors.
After the problem has been defined, formulate a simple, efficient, and effective approach to solve the
problem. The second step usually involves breaking down the problem into smaller sub-problems.
The third step may be expressed in human language, (English, Tagalog), graphical representation
(flowchart), or pseudocode (a cross between human language and a programming language).
After the algorithm has been constructed, a source code is created. Using the algorithm as a basis, the
source code can be written using the desired programming language.
PROGRAMMING LANGUAGES (CSS 2) / LORIE AVILLANOZA 2
Lesson 02: ALGORITHM
• A step-by-step problem-solving procedure
• Finite sequence of steps for solving a logical or mathematical problem.
• A specific set of well-defined, simple mathematical and logical procedures that can be followed to
solve a problem in a finite number of steps.
An algorithm is a finite set of well-defined instructions for accomplishing a task which, given an initial
state, will result in a corresponding recognizable end-state. Algorithms can be implemented by computer
programs, although often in restricted forms; an error in the design of an algorithm leads to failure in
implementing the program.
We use algorithms every day. For example, a recipe for baking a cake is an algorithm. All programs
consist of algorithms may it be simple or complex. Inventing elegant.
algorithms – algorithms that are simple and require the fewest steps possible – are one of the principal
challenges in programming.
Baking a chocolate cake, computing for average grade, or going from one location to another are
examples of everyday life algorithms.
Guide to a good Algorithm
1. Specify each step or instruction exactly.
2. There must be a finite number of steps.
3. There must be an output.
• Specify each step or instruction exactly – There must be no ambiguity or the instructions must be
clear.
• There must be a finite number of steps – The algorithm must terminate and should have a stopping
point.
• There must be an output – The algorithm must produce the correct result.
Various methods and tools are used to represent/describe algorithms and programs.
Examples of which are pseudocodes and flowcharts.
Lesson 03: PSEUDOCODES
• Generic way of describing an algorithm without the use of any specific programming language
syntax.
• Models and resembles real programming code
While not at end of list compare adjacent elements if elements were switched repeat for entire list.
PROGRAMMING LANGUAGES (CSS 2) / LORIE AVILLANOZA 3
Pseudocode is a shorthand way of describing a computer program. Rather than using the specific syntax
of a computer language, more general wording is used. It is easier for a non-programmer to understand
the general workings of the program using pseudocode. For example, the pseudocode for a bubble sort
routine might be written:
While not at end of list compare adjacent elements if second is greater than first switch them get next
two elements if elements were switched. repeat for entire list.
Pseudocode consists of short English phrases used to explain a specific task within a program's
algorithm. The rules of Pseudocode are reasonably straight forward. All statements showing
"dependency" are to be indented which include while, do, for, if, and switch.
A pseudocode cannot be compiled nor executed, and there is no real formatting or syntax rules for it. It
is simply an important step in producing the final code. The benefit of a pseudocode is that it enables the
programmer to concentrate on the algorithm without worrying about all the syntactic details of a
particular programming language. In fact, you can write a pseudocode without even knowing what
programming language you will use for the final implementation.
Lesson 04: FLOWCHART
A flowchart is a graphical representation of a sequence of operations. In programming, a flowchart
contains symbols describing how an algorithm or program operates. It is also defined as a graphic map
of the path of control or data through the operations in a program or an information handling system.
Symbols such as rectangles, diamonds, and ovals represent various operations. These symbols are
connected by directed lines to indicate the flow of data or control from one point to another.
• A chart that contains symbols referring to computer operations, describing how the program
performs.
• A graphic map of the path of control or data through the operations in a program or an information-
handling system.
• Symbols such as squares, diamonds, and ovals represent various operations.
• These symbols are connected by lines and arrows to indicate the flow of data or control from one
point to another.
Terminal block
Process block
PROGRAMMING LANGUAGES (CSS 2) / LORIE AVILLANOZA 4
Input/output block
Decision block
Flow Lines
Flow Lines
indicated by directed lines to show the direction of data or the control flow. The arrowhead is sometimes
not shown when the direction of flow is clear. Flow lines are used to connect blocks by exiting from one
and entering another.
• Indicated by straight lines with arrows to show the direction of data flow.
• The arrowhead is sometimes not shown when the direction of flow is clear.
• used to connect blocks by exiting from one and entering another.
Terminal block
Ovals or rounded rectangles in a flowchart are called Terminal Blocks. These blocks are used to indicate
the start and end of a module or program. An oval is labeled with the name of the module at the start.
The end is indicated by the word end or stop for the top or Control Module. A start has no flow line
entering it and only one exiting it. On the other hand, an end or exit has one flow line entering it but
none exiting it.
PROGRAMMING LANGUAGES (CSS 2) / LORIE AVILLANOZA 5
• Ovals or rounded rectangles used to indicate the start and the end of a module or program.
• An oval is labeled with the name of the module at the start.
• The end is indicated by the word end or stop for the top or Control Module
START
END
Initialization block
The hexagon, which is called an initialization block, is used for declaring / initializing variables. It has
one entrance and one exit. You can only use variables that had been initialized.
• used for declaring / initializing variables needed to solve a certain process.
• Declaration:
✓ binding of an identifier to the information that relates to it
✓ stating a variable name to be used
X = 10
• Initialization:
✓ to set (a starting value of a variable) Y = 25
✓ to prepare (a computer or a printer) for use;
✓ to format boot (a storage medium, such as a disk)
Process block
The rectangle indicates a processing block, for such things as calculations, opening and closing files,
and so forth. A processing block has one entrance and one exit.
• the rectangle indicates a processing block
• has one entrance and one exit
X=Y+Z
Input / Output block
A = 18
The parallelogram indicates general input and output operations.
An I/O block has one entrance and only one exit. B=A-2
Get X Display X
PROGRAMMING LANGUAGES (CSS 2) / LORIE AVILLANOZA 6
Decision block
The diamond or "Decision block" indicates a decision. It has one entrance and exactly two exits from the
block. Entry/exit points are through the vertices. It is a logical statement that should evaluate to TRUE
or FALSE. Exit points are be labeled to indicate when each will be used (e.g., using T and F, or to be
more readable, using Yes or Y and No or N.
One exit is the action when the resultant is TRUE and the other exit is the action when resultant is
FALSE.
• the diamond indicates a decision
• has one entrance and exactly two exits from the block
T F
Condition
Action when Action when
TRUE FALSE
Connectors
Circles or Connectors are used for in-page connectors, labeled with uppercase letters while pentagons
are used for off-page connectors, labeled with uppercase letters and a number (typically the page number
of the matching pair). The circle is used as a connection point between two sections of a flowchart that
are not adjacent or closely located to each other. These connectors should be used as little as possible.
They should only be used to enhance readability. Overuse, however, decreases readability and produces
a cluttered effect.
These connectors should be used as little as possible. Overuse, however, decreases readability and
produces a cluttered effect.
• the circle is used as a connection point between two sections of a flowchart that are not adjacent or
closely located to each other.
• used to enhance readability.
PROGRAMMING LANGUAGES (CSS 2) / LORIE AVILLANOZA 7
FLOWCHART: EXAMPLE 1
The equal (=) sign in the statement Age = Age + 5 is read as Age gets the sum of Age plus 5. It is not
interpreted as an equation of equality.
• Create a flowchart that displays your age five years from now.
Start
Age = 18
Age = Age + 5
Display Age
Stop
• This flowchart shows that the value will increase to 5 if it is greater than 10 and display the result;
otherwise no action shall be done.
Start
FLOWCHART: EXAMPLE 2
• Create a flowchart that will increase the value of the
number by 5 if it is greater than 10 and display the x=0
result; otherwise no action shall be done
Get x
Yes No
x>
10?
x=x+5
Display x
Stop
PROGRAMMING LANGUAGES (CSS 2) / LORIE AVILLANOZA 8
FLOWCHART: EXAMPLE 3
• Create a flowchart that displays the user’s name, birthday, age, gender, and phone number. Your
flowchart should display the variables with the following format:
Name: ?????? ANSWER:
Age: ?? Start
BDay: ?????????
Gender: ?
Phone#: ???????
Name=“”
BDay=“”
Age=0
Gender=‘ ’
Pno=“|”
Get Name, BDay,
Age, Gender, Pno
Display “Name:” Name
“Age:” Age
“BDay:” BDay
“Gender:” Gender
“Phone#:” Pno
Stop
FLOWCHART: EXAMPLE 4
• Create a flowchart that will compute for the Average score of a student based on three quizzes. The
quiz scores are integers that may range from 0 to 100 and are entered by the user. The Average may
be a decimal number.
Q1: 98 Q2: 79
Q3: 88 Ave is 83.33
PROGRAMMING LANGUAGES (CSS 2) / LORIE AVILLANOZA 9
ANSWER: Start
Set Sum, Ave,
Q1, Q2, Q3 to 0
Get Q1, Q2, Q3
Sum=Q1+Q2+Q3
Ave=Sum/3
Display Ave
Stop
Activity :
ACTIVITY 1:
Directions: Draw a flowchart for a college’s admissions office with the following specifications:
• Allow the user to input the student’s high school GPA and admission test score.
• Print the message “Accept” if the student has a grade point average of 3.0 or above and an admission test
score of at least 60.
• If the student does not meet either of the qualification criteria, print “Reject”.
ACTIVITY 2:
Directions: Draw a flowchart for a college’s admissions office with the following specifications:
• Create a flowchart that will increase the value of the number by 5 if it is greater than 10 and display the result.
Otherwise, multiply the value by 5 and display the result.
PROGRAMMING LANGUAGES (CSS 2) / LORIE AVILLANOZA 10
References :
• Department of Technology Education at The University of Southern
Mississippi. (2007, February 26). Retrieved from
Dragon.ep.usm.edu/~it365/module/Basics/system.htm
• Hoffer J., George G., & Valacich J. (2008). In 5 Ed., Modern systems
analysis and design. Pearson Prentice Hall.
• Parsons J. J., & Oja D. (2010). In 8 Ed., Computer concepts Illustrated
Introductory. Cengage Learning.
PROGRAMMING LANGUAGES (CSS 2) / LORIE AVILLANOZA 11