Lesson 1:
Introduction to Program Logic
Formulation and Program Coding
Prepared by:
Raymond M. Cruz
OBJECTIVES
After the completion of the chapter, students will be able to:
1. Understand the algorithms, as part of software development;
2. Define and identify the symbols used in flowcharting;
3. Analyze and create pseudocode and flowchart in solving a problem;
and
4. Design an algorithms, pseudocode, and flowchart in solving a
problem.
There are two commonly used tools to help document program logic (the algorithm):
1. Pseudocode
2. Flowchart FLOWCHART
- is a tool developed in the computer
industry, for showing the steps involved in
a process.
- Flowcharting combines symbols and
flowlines, to show figuratively the
operation of an algorithm.
- Is a pictorial representation of step by step
instructions to solve a problem.
PSEUDOCODE
How to get ready for school:
1. Wake up.
2. Eat breakfast.
3. Practice good hygiene.
4. Get dressed.
5. Take everything you need.
6. Head out the door.
7. Ride your school bus.
FLOWCHART
How to get ready for school:
FLOWCHARTING SYMBOLS
Symbol Name Description
Terminator Represents a start or end point of the process.
Input/Output Represents information entering or leaving
the system.
Process Indicates some particular operation.
Decision Represents a decision or branching point.
Represents a set-up to another step in the
Preparation process.
Off-page Connector Indicates that the process continues off page.
On-page Connector Indicates that the flow continues somewhere
else on the same page.
Flow lines Shows the order of the process.
EXAMPLES
START
FLOWCHART
BASIC ARITHMETIC
Print “Enter your
nickname:”, nname.
PSEUDOCODE
Step 1: Start Print “Enter first
Step 2: Print “Enter your nickname”, nname. number:”, fnum.
Step 3: Print “Enter first number:”, fnum.
Step 4: Print “Enter second number:”, snum. Print “Enter second
number:”, snum.
Step 5: Subtract snum from fnum for the value
of difference.
Step 6: Print “Good day,”, nname, “!”. difference = fnum - snum
Step 7: Print “The difference of”, fnum, “and “,
snum, “is “, difference Print “Good day,”, nname, “!”.
Step 8: End
Print “The difference of”, fnum,
“and “, snum, “is “, difference
END
DECISION MAKING START FLOWCHART
PSEUDOCODE Print “Enter first
number:”, fnum.
Step 1: Start
Step 2: Print “Enter first number:”, fnum.
Print “Enter second
Step 3: Print “Enter second number:”, snum. number:”, snum.
Step 4: If fnum is greater than the value of snum.
Step 4.1: Print fnum, “ is greater than “, snum.
Step 5: Else, print snum, “ is greater than “, fnum. if fnum T Print fnum, “ is
> greater than “, a
Step 6: End snum snum.
F
Print snum, “ is
greater than “,
fnum
END
START FLOWCHART
LOOPING
current_year=2020
PSEUDOCODE
Print “Enter your name:”, name. a
Step 1: Start
Step 2: Read current_year=2020 Print “Enter your birth
Step 3: Print “Enter your name:”, name year:”, birth_year.
Step 4: Print “Enter your birth year:”, birth_year
Step 5: The value of age is equal to current_year age = current_year – birth_year
minus birth_year.
Step 6: Print “Hi”, name, “! You are ”, age, “ years
old this year 2020.” Print “Hi”, name, “! You are ”,
age, “ years old this year 2020.”
Step 7: Print “Do you want to try again? (Y or N)”,
answer
Step 8: Check if answer is equals to ‘Y’. Print “Do you want to try again?
(Y or N)”, answer
Step 8.1: Then, go to Step 3.
Step 9: Else, print “Thank you!”
Step 10: End if T
answer a
== “Y”
F
1
LOOPING
PSEUDOCODE 1 FLOWCHART
Step 1: Start
Step 2: Read current_year=2020
Step 3: Print “Enter your name:”, name Print “Thank you!”
Step 4: Print “Enter your birth year:”, birth_year
Step 5: The value of age is equal to current_year
minus birth_year.
Step 6: Print “Hi”, name, “! You are ”, age, “ years END
old this year 2020.”
Step 7: Print “Do you want to try again? (Y or N)”,
answer
Step 8: Check if answer is equals to ‘Y’.
Step 8.1: Then, go to Step 3.
Step 9: Else, print “Thank you!”
Step 10: End
Thank you and God bless!
___