You are on page 1of 31

LOGIC FORMULATION

Logic Formulation
 Defines Algorithm and Flowchart
 Understand the use of Algorithm and
flowchart
 Learn the guidelines for drawing a
flowchart
 Create flowcharts
Algorithms
 The solution to any computing
problems involves executing a series
of actions in a specific order

◼ A procedure for solving a problem in


terms of:
◼ The actions to be executed, and
◼ The order in which these actions are to be
executed.
Example:

 Get out of bed


 Take off pajamas
 Take a shower
 Get dressed
 Eat breakfast
 Get ready to work
Flowchart
 is a graphical representation of an
algorithm.
◼ Uses of Flowchart
◼ To test the validity of the statements entered
in a program.
◼ To determine if the sequence of instruction is
correct.
Example as a flowchart
Process starting
Point

HEAD
Steps in the Process

Decision
BODY

End
TAIL
Different symbols
used in flowcharting.
The Terminal Symbols

Start / End

It represents the beginning and end of a program or point of


interruption in a program.
Preparation Symbol

Sum = 0
X=5
Y = 10
Name = “ ”

It indicates the initialization of certain variables to given


values, usually 0 for numeric variables and null for string
variables.
The Input/Output Symbol

Display: sum
Input: x,y

It represents an activity to an input or an output device.


The Process Symbol

Sum = A + B

It represents an instruction that involves arithmetic


calculations or assigning a value into a variables.
The Decision Symbol

YES
If age = 40

It signifies a
decision usually
expressed in an IF…
THEN statement.
NO
The Connector Symbol

A
A
It is used to designated an entry
from or an exit to another part of
the flowchart on the same page.
Off-Page Connector Symbol
Next Page

B
B
End of the Page

Shows an exit to or an entry to another


part of the flowchart on a different
page.
Flowlines

Used to show the direction of flow of


data and the sequence of instruction in a
program.
Guidelines in Flowcharting
 A flowchart always begins with a START and is completed
by END/STOP.
 Symbols are interconnected by headed arrows.
 An arrowhead indicates the direction to be followed. The
normal direction of flow in a flowchart is from top to bottom
and from left to right.
 An oblong, hexagon, parallelogram, rectangle or circle may
have only arrow branching out, but may have one or more
arrows branching in.
 A diamond must have more than one arrow branching out,
but may have one or more arrows branching in.
 Whenever circles are used, the symbol leading to a circle
should flow to the symbol where a circle containing a
similar character leads to.
 The sequence of symbols matters. It indicates a step-by-
step logic to be followed.
Example:

Create a flowchart
that will input 3
student name and
display.
START a

Input z
X,y,z = “ “

Display x,y,z
Input x

Input y STOP

a
Activity #1

Create a flowchart
that will input 3
numbers and
display the sum
the 3 numbers.
START

a..j = 0
Sum = 0
Display sum

Input: a..j

STOP

Sum=a+b+..+j

a
Activity #2

Create a flowchart that


will input 3 students
name and their age.
Display the student
name and age.
b
a
START

Input c
Input z
X,y,z = “ “
a,b,c = 0

Display x,y,z
Input a
Input x

Display a,b,c
Input b
Input y

b Stop
a
Activity #4

Given the length and


width of a rectangle,
prepare a flowchart to
compute the area.
Quiz

Given the amount in


pesos, convert it to
dollar. Assume Php
43.53 = $1.00.
Assignment

•Create a flowchart that will


input 10 score. Compute
the average. And display
the average.
Flowchart
a b c
START
Sum=s1+s2+s3+s4
Input: s3 Input: s7
s1,s2,s3,s4,s5, +s5+s6+s7+s8+s9
s6,s7,s8,s9,s10 = 0 +s10
Sum = 0
Ave = 0
Input: s4 Input: s8
Ave= sum/10

Input: s1
Input: s9
Input: s5

Display ave
Input: s2
Input: s10
Input: s6

a c STOP
b
Activity #1

Create a flowchart that


will input 3 numbers
and if the sum of the 3
numbers are even then
display “Hello”, if not
display “Hi”.
a b
START

Input: z
If(
x,y,z= 0 (sum%2) yes
Display “Hello”
Sum = 0 =0)

Sum=x+y+z
Input: x no

Display “Hi”
b
Input: y

a STOP
Activity #2
Create a flowchart that will
input the student name
and age. If the age is equal
or less than 19 the display
“Teenager”, if not then
display “Adult”.
Activity#2:
a
START

If age yes
<= Display “Teenager”
name= “”
age = 0 19

no
Input: name

Display “Adult”

Input: age

STOP
a
Seatwork
Create a flowchart the will input student
name and 5 quiz, compute the
average of the quizzes. If the
average is below 75 display “FAILED”
or else display “PASSED”.

You might also like