0% found this document useful (0 votes)
28 views29 pages

Dsalesson2 Algorithmandflowcharting 231022185804 4071957a

Algorithm
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
28 views29 pages

Dsalesson2 Algorithmandflowcharting 231022185804 4071957a

Algorithm
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 29

ALGORITHM AND

FLOWCHARTING
Lesson 2 – Data Structures and Algorithm

MR. ROWELL L. MARQUINA


IT Instructor, PUP Biñan
WHAT IS AN
ALGORITHM?
What is an Algorithm?
An algorithm refers to a series of well-defined
instructions on how to accomplish a task or
solve a specific problem.
▪ Giving directions on how to get to
somebody’s house is an algorithm.
▪ The steps on how to change a light bulb is
an algorithm.
▪ The steps to compute the for average is
also an algorithm.

IMAGE SOURCE: https://imgbin.com/png/uxvDNRys/computer-programming-computer-icons-technology-algorithm-png


https://www.flaticon.com/free-icon/coding_1085774
STEPS IN DEVELOPING AN ALGORITHM:
1. In creating an algorithm, it is very important to determine the
exact goal or expected product first. The goal or expected
product of the algorithm is called OUTPUT.
2. After determining the output, the next step is to identify the
necessary materials or elements needed to accomplish the
task. The elements needed for the program is called INPUT.
3. If the input and output are already identified, it is time to list
the steps needed to accomplish the task. The steps needed
to accomplish the task is referred to as the PROCESS.
CHARACTERISTICS OF AN ALGORITHM:
An algorithm should possess the following characteristics:
▪ It should have well-defined input and output.
▪ The steps should be stated clearly and unambiguously.
▪ It should have an exact start and end.
▪ It should be simple but precise.
▪ It should be practical.
WHAT IS
FLOWCHART?
What is a Flowchart?
A flowchart is a diagram that
illustrates a process, system or
computer algorithm.
Flowcharts are widely used in
multiple fields for the purpose of:
▪ documentation
▪ planning
▪ analysis
▪ presentation

IMAGE SOURCE: https://www.frevvo.com/blog/wp-content/uploads/2021/10/image5-2.png


Flowchart Symbols
The American National Standards
Institute (ANSI) set standards for
flowcharts and their symbols in the
1960s.
In 1970 the International Organization
for Standardization (ISO) adopted the
ANSI symbols as the international
standard for developing flowcharts.

IMAGE SOURCES:
https://upload.wikimedia.org/wikipedia/commons/thumb/9/93/ANSI_logo.svg/1200px-ANSI_logo.svg.png
https://1000logos.net/wp-content/uploads/2020/09/ISO-Logo.png
Flowchart Symbols

IMAGE SOURCES:
https://uploads-ssl.webflow.com/6184b461a39ff13bfb8c0556/61de99e8171cc6468145551d_flowchart-symbols-800.png
Flowchart Symbols
NAME OF SYMBOL SYMBOL FUNCTION
Indicates the beginning and end of the
Terminal Symbol
flowchart.
Its shows the process’ direction or the
Flowline Symbol
next steps in the process.
It shows the process or operations to be
Process Symbol
carried out by the program

It shows the step that contains a control


Decision Symbol
mechanism or decision.

It indicates the process of getting data


Input/Output Symbol from the user or displaying data on
screen.
SAMPLE FLOWCHART 1:

DETERMINING USER’S AGE


Create a flowchart for a program that will
require the user to input their year of birth. Using
the user’s year of birth, the program will
compute for the user’s age and display its result
on the computer screen.
START The program is initiated.

The variables birthyear and age were introduced to the


birthyear, age
program.

display The program displays the instruction “Enter Year of Birth: ”


“Enter Year of Birth:” on the screen.

input The program get an input from the user and store its value in
birthyear the variable birthyear.

The program computes for the value of age using the


age = 2023 - birthyear
formula age = 2023 - birthyear.

display
The program displays the value of age on the screen.
age

END The program is terminated.


SAMPLE FLOWCHART 2:
CONVERTING FROM KILOGRAM TO POUND
Create a flowchart for a program that will require
the user to input a value in kilogram (kg). The
program will convert the inputted value into
pounds (lbs.) and display its results on the screen.
START The program is initiated.

The variables kilo and pound were introduced to the


kilo, pound
program.

display
The program displays the instruction “Enter Weight in
“Enter Weight in
Kilogram: ” on the screen.
Kilogram:”

input The program get an input from the user and store its value in
kilo the variable kilogram.

pound = kilo * 2.2 The program computes for the value of pound using the
formula pound = kilo * 2.2.

display
pound The program displays the value of pound on the screen.

The program is terminated.


END
SAMPLE FLOWCHART 3:
COMPUTING FOR AREA:
Create a flowchart for a program that will require
the user to input the length and width of a
rectangle. The program will compute for the area
of the rectangle using the inputted length and
with and display its results on the screen.
START The program is initiated.

length, width, area The variables length, width, and area were introduced to
the program.

display The program displays the instruction “Enter Length: ” on


“Enter Length:” the screen.

input The program get an input from the user and store its value in
length the variable length.

display The program displays the instruction “Enter Width: ” on


“Enter Width:” the screen.

input The program get an input from the user and store its value
width in the variable width.

A The program will be continued on the next slide.


A The program is continued.

The program computes for the value of area using the


area = length * width
formula area = length*width.

display
The program displays the value of area on the screen.
area

END The program is terminated.


SAMPLE FLOWCHART 4:
PLAYING WITH NUMBERS
Create a flowchart for a program that will require
the user to input four numbers. Using the inputs,
the program will compute for:
▪ the sum of 1st and 2nd number,
▪ the product of the 3rd and 4th number
▪ the square of the 2nd number
START The program is initiated.

num1, num2, num3, num4, The variables num1, num2, num3, num4, sum,
sum, product, square product, and square were introduced to the program.

display The program displays the instruction “Enter the First


“Enter the First Number: ” on the screen.
Number: ”

input The program get an input from the user and store its value in
num1 the variable num1.

display The program displays the instruction “Enter the Second


“Enter the Second Number: ” on the screen.
Number: ”

input The program get an input from the user and store its value
num2 in the variable num2.

A The program will be continued on the next slide.


A
The program is continued.

display The program displays the instruction


“Enter the Third “Enter the Third Number: ” on the screen.
Number: ”

input The program get an input from the user and store its value in
num3 the variable num3.

display The program displays the instruction


“Enter the Fourth “Enter the Fourth Number: ” on the screen.
Number: ”

input The program get an input from the user and store its value
num4 in the variable num4.

The program computes for the value of sum using the


sum = num1 + num2
formula sum = a + b.

B The program will be continued on the next slide.


B The program is continued.

The program computes for the value of product using


product = num3 * num4
the formula product = num3*num4.

The program computes for the value of square using


square = num2 * num2 the formula square = num2 * num2.

display
The program displays the value of sum on the screen.
sum

display The program displays the value of product on the screen.


product

display
The program displays the value of square on the screen.
square

END The program is terminated.


SAMPLE FLOWCHART 5:
PLAYING WITH NUMBERS
Create a flowchart for a program that will require
the user to input four numbers. Using the inputs,
the program will compute for:
▪ the cube of the 1st number,
▪ the half of the 2nd number,
▪ the 20% of the 3rd number,
▪ The product of multiplying the 4th
number by 100
START The program is initiated.

The variables num1, num2, num3, num4, cube, half,


num1, num2, num3, num4,
twentyp, and times100 were introduced to the
cube, half, twentyp, times100
program.

display The program displays the instruction “Enter the First


“Enter the First Number: ” on the screen.
Number: ”

input The program get an input from the user and store its value in
num1 the variable num1.

display The program displays the instruction “Enter the Second


“Enter the Second Number: ” on the screen.
Number: ”

input The program get an input from the user and store its value
num2 in the variable num2.

A The program will be continued on the next slide.


A
The program is continued.

display The program displays the instruction


“Enter the Third “Enter the Third Number: ” on the screen.
Number: ”

input The program get an input from the user and store its value in
num3 the variable num3.

display The program displays the instruction


“Enter the Fourth “Enter the Fourth Number: ” on the screen.
Number: ”

input The program get an input from the user and store its value
num4 in the variable num4.

The program computes for the value of cube using the


cube = num1 * num1 * num1
formula cube = num1 * num1 * num1.

B The program will be continued on the next slide.


B The program is continued.

The program computes for the value of half using the


half = num2 / 2
formula half = num2 / 2.

twentyp = num3 * 0.20 The program computes for the value of twentyp using
the formula twentyp = num3 * 0.20.
The program computes for the value of times100
times100 = num4 * 100
using the formula times100 = num4 * 100.

display The program displays the value of cube on the screen.


cube

display
The program displays the value of half on the screen.
half

display The program displays the value of twentyp on the screen.


twentyp

display The program displays the value of times100 on the screen.


times100

END The program is terminated.


PRACTICE TEST 1:
DOLLAR TO PESO CONVERSION
Create a flowchart for a program that will require
the user to input the amount in US Dollars. Using
the inputted amount, the program will convert it
to its Philippine Peso value and display the answer
on the screen.
Note: 1 US Dollar = Php 56.78
PRACTICE TEST 2:
COMPUTING FOR AVERAGE
Create a flowchart for a program that will require
the user to input their grades in Mathematics,
English, and Science. The program will compute
for the average of the three grades and display
its result on the computer screen.
PRACTICE TEST 3:
PLAYING WITH NUMBERS
Create a flowchart for a program that will require
the user to input four numbers. Using the inputs,
the program will perform the following:
▪ display the 1st number,
▪ get the product of 1st and 3rd number,
▪ get the product of multiplying the 2nd number
by the sum of the 3rd and 4th number,
▪ the average of the four numbers increased by 5.
ALGORITHM AND
FLOWCHARTING
MR. ROWELL L. MARQUINA
Professional Lecturer,
Polytechnic University of the Philippines

Email Address:
[email protected]
[email protected]
[email protected]

You might also like