Computer Programming Chapter 2.1
Computer Programming Chapter 2.1
z
&
FLOWCHARTING
ALGORITHMS
▪ is a sequence of
activities to be processed
for getting desired output
from a given input,
according to Mahdi
(2013)
ALGORITHMS
▪ is a step-by-step procedure
to solve a particular problem
▪ must be specific, and it
should have a starting point
and it should terminate or
end
FLOWCHART
▪ is a graphical representation
of an algorithm
▪ It describes the operations
required to solve a given
problem
An algorithm is just a
sequence of steps in solving
a problem while flowchart
can be used to represent
algorithm graphically
(Programiz, 2018).
SYMBOLS USED IN FLOWCHART
SYMBOLS USED IN FLOWCHART
FLOWCHART EXAMPLE
Example 1:
Create a flowchart that
will display the sum of
two numbers
Algorithm:
1. Get the first number and
the second number.
2. Calculate the sum using
this formula:
sum = firstnum + secondnum
3. Display the sum.
FLOWCHART FOR EXAMPLE 1
Example 2:
Create a flowchart that
computes for the average
of two numbers and
display the result
Algorithm:
1. Get the first number and
second number.
2. Calculate the average
using this formula:
average = (firstnum + secondnum) / 2
3. Display the average.
FLOWCHART FOR EXAMPLE 2
LOGICAL OPERATORS
▪ are used in programming
to connect two or more
expression
▪ It is also used to control
program flow (Drakos,
1997)
LOGICAL OPERATORS
▪ can only be used with
expressions whose
results are logical values
such as true or false
LOGICAL OPERATORS
To fully understand the logical operators
let’s have these truth tables
Let’s now how have an
example of logical operators
=False
=False
=True
Let’s now how have an
example of logical operators
=True
=True
RELATIONAL OPERATORS
According to Busbee (2018) “A
relational operator is a programming
language construct or operator that
tests or defines some kind of relation
between two entities.” This is also
called as Boolean expression. A
Boolean value can either be true or
false.
RELATIONAL OPERATOR ON
FLOWCHART
Example 1:
Create a flowchart that determines
the greater number between two
numbers entered by the user.
Let:
First Number = n1
Second Number = n2
REPETITION CONTROL
STRUCTURE
Repetitive control structures are
also called iterative structures,
these structures are group of
codes that are designed to repeat
a set of related statement
REPETITION CONTROL
STRUCTURE
There are two types of repetition
control structure; Pre-test Loop
and Post-test Loop (Thomas,
2007).
REPETITION CONTROL
STRUCTURE
In the pre-test loop, the condition is
tested first before executing the
statement while in the post-test loop
the statement is executed first
before the condition is tested.