Download as pptx, pdf, or txt
Download as pptx, pdf, or txt
You are on page 1of 11

ALGORITHM

ELEMENT OF ALGORITHM

VARIABLES
Math:
A letter that can represent any
number

Programming:
A letter/word that serve as a
temporary storage that can
represent any value
ELEMENT OF ALGORITHM

VARIABLES
RULES IN CREATING VARIABLES
• Do not use special characters ( *,/,\,
#)
• Don’t start in numbers (Ex. 1A, 2B, 3C)
• Start with letters
ELEMENT OF ALGORITHM

SYMBOLS
’+’ for Addition
’-’ for Subtraction
’*’ for Multiplication
’/’ for Division
’=’ Assignment operator
, Separator
; End of statement
TYPES OF ALGORITHM

SEQUENCE REPETITION

1 2 3

SELECTION
PROCESS
• Input
• Process
• Output

SEQUENCE REPETITION

1 2 3

SELECTION
WE CAN CREATE MANY
POSSIBLE ANSWER
Solution B

Solution A Solution C
HOW TO WRITE
SEQUENCE
ALGORITHM
NEED TO REMEMBER
 Writing algorithm does not have any well defined-
standards

 Algorithms are never created to support a specific


programming language

 As well know, basic code features such as loops (do,


for, whole all programming language share), flow
control (if-else), and so on.

 We usually create algorithms step by step; however,


this isn’t always the case.

 After the problem domain has bee well-defined,


algorithm writing is a procedure that is carried
out.
PROBLEM #1 SEQUENCE ALGORITHM

1. Write an algorithm to read two


numbers and find their sum.

REMINDER: For to create an algorithm you have to


identity first the variables, input and output.

Step 1. Define the variables needed


Step 2. Initialize the value for each variables
Step 3. Input value of variables
Step 4. Process the sum of two numbers
Step 5. Display output
PROBLEM #2
2. Create a algorithm that will display the sum of 2
numbers inputted by the user.

PROBLEM #3
3. There are 45 carpenters in a crew. On a certain
day, 9 were present. What percent showed up for work?

Using this Formula:


R= P/B

You might also like