0% found this document useful (0 votes)
23 views

01 Basic Programming Constructs

Uploaded by

shan.forstudies
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
23 views

01 Basic Programming Constructs

Uploaded by

shan.forstudies
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 26

BASIC

PROGRAMMING
CONSTRUCTS
Learning Outcome:
Use algorithms in solving programming problems.
Programming
-the process or skill or writing programs for computers.
-the instructions that tell a computer on what to do.
ALGORITHM
Algorithm is a finite set of instructions that specify a
sequence of operations to be carried out in order to solve a
specific problem or class of problems.
- It can be presented in a form of flowchart or pseudocode.

https://www.slideshare.net/AngelaDeHart/what-is-an-algorithm-130758029?from_action=save
Flowchart
Flowchart is a tool that programmers use to help them plan
an algorithm which consists of standardized symbols
connected by flowlines. It uses standardized symbols to
visually depict an algorithm.

MS visio
Diagram designer
Lucidchart online
Basic Symbols Used in Flowcharting
Symbols What it represents
Terminal It is used to represent the start and end of a
process.
Preparation/Initialization It signifies the preparation of data which is
used to select initial conditions. It is also
used to represent instructions or group of
instruction that will alter or modify a
program’s course of execution.
Input/Output It shows input and output. Data that are to
be read into the computer memory from an
input device are to be passed from the
memory to an output device.
Processing It performs any calculations that are to be
done.
Basic Symbols Used in Flowcharting
Symbols What it represents
Decision It signifies any decisions that are to be done. Two
alternative execution paths are possible, the path to be
followed is selected during the execution by testing
whether or not the condition specified within the
outline is fulfilled. This is where the True and False
condition goes.
On-page connector It shows the entry or exit point of the flowchart. A non-
processing symbol which is used to connect one part of
a flowchart to another without drawing flowlines. It
conserves space by keeping related blocks near one
another, reduces the number of flowlines in complex
program, and eliminates cross lines from taking place.
Basic Symbols Used in Flowcharting
Symbols What it represents

Off-page It designates entry to or exit from one


connector page when a flowchart requires more
than one page.
Flowlines It signifies the process that is to be
executed next.
Pseudocode
Pseudocode is composed of short English statements
composing false code since it only resembles
programming language instructions but cannot be
understood by a computer. Programmers use
pseudocode to help them while they are planning an
algorithm.
ALGORITHM –Pseudocode
For example, an algorithm for driving to a friend's house could be:
1. Find your keys
2. Walk out of the house
3. Close the door
4. Open the car door
5. Get into the car
6. Put the key into the ignition, etc…..

https://www.slideshare.net/AngelaDeHart/what-is-an-algorithm-130758029?from_action=save
Example – (Algorithm: Pseudocode)
1. Enter the price of the ballpen, quantity and cash given.
2. Calculate the total amount by multiplying the price of the
ballpen to the quantity then calculate the change by
subtracting the total amount from the cash given.
3. Display the total amount and the change.

PROBLEM: Adrian buys two ballpens in the bookstore. Each costs P 7.50.
His money is P50.00. How much is the total amount of the
ballpen and his change?
Example – (Algorithm: Flowchart)
Start

Enter the price of the ballpen,


quantity and cash given

total amount = price of the ballpen * quantity

change = cash given – total amount

display total amount, change

Stop
IPO (Input, Process, Output)
IPO is an acronym for Input, Process and Output.
Some programmer use an IPO chart to organize and
summarize the results of the analysis step and to
record the input items in the Input column, record the
needed process in the Processing column, and record
the output items in the Output column.
IPO Example
Input Column Process Column Output Column
price of the ballpen processing items: Total amount of
quantity total amount = 2 ballpens x 7.50 the two
cash given (50.00) change = cash given – total amount ballpens
Change of 50.00
HANDS-ON ACTIVITY:
Draw a Flowchart on the
given situations.
Criteria Advanced Proficient Functional Developing Score
4 3 2 1
Correctness of All symbols 1 or 2 symbols More than 3 All symbols are
Symbols used are are not symbols are not properly
correct. properly not properly used.
placed. used.
Organization Good Organized, Some Not organized,
and Layout organization, flow for the organization, flow makes no
flow is logical most part is flow slightly sense and is
Writing and easy to
follow.
clear. unclear not clear

Algorithms Quality and


Accuracy of
Steps are very
specific to
Some details
are not
Details are
somewhat
Unable to find
specific details

Rubric Information process and


accurate
relevant to
process and
chart contains
ambiguous
and/or
somewhat
and/or details
are mostly
accurate
few inaccurate
inaccuracies
Consistency of Word/words 1 or 2 words More than 3 All words
Symbols and placed in the placed in the words placed placed in the
Statements symbols are all symbols are in the symbols symbols are
correct incorrect are incorrect incorrect
Neatness Excellent use Use of arrows Some use of No use of
of flowchart and correct arrows and/or arrows and/or
format; not at format of a format of a format of a
all confusing flowchart; flowchart; flowchart;
slightly somewhat confusing and
confusing confusing untidy

TOTAL
WHAT IS YOUR
ALGORITHM FOR
GETTING TO THIS
CLASS?
WHAT IS YOUR
ALGORITHM IN
SOLVING THE
VELOCITY?
WHAT IS YOUR
ALGORITHM FOR
GETTING UP ON
SUNDAYS?
WHAT IS YOUR
ALGORITHM IN
SOLVING THE AREA OF
A TRIANGLE?
WHAT IS YOUR
ALGORITHM IN
ORDERING FOOD
USING FOOD PANDA?
WHAT IS YOUR
ALGORITHM FOR
EATING BREAKFAST?
WHAT IS YOUR
ALGORITHM IN PAYING
YOUR TUITION FEE AT
THE MU ACCOUNTING?
WHAT IS YOUR
ALGORITHM IN
PLAYING MOBILE
LEGENDS?
WHAT IS YOUR
ALGORITHM IN RECEIVING
A MONEY FROM PALAWAN
PAWNSHOP?
WHAT IS YOUR ALGORITHM
FOR SUBSCRIBING OR
PURCHASING NETFLIX
ACCOUNT?

You might also like