Algorithm and Flowchart
Algorithm and Flowchart
Objectives:
1. identify the difference process in solving programming
problems;
2. Explain what algorithm and flowcharts are;
3. Recognize the importance of algorithms and flowcharts
4. Create an algorithm and flowchart.
Problem-Solving Process in PROGRAMMING
LIBRARY
HUMAN
010101010
INTRUCTIONS
PROBLEM 01101010 SOLVE
PROGRAM
001010101
CODE
Step 1. Start
Step 2. Add tow teaspoons of coffee in a mug.
Step 3. Pour the hot water in a mug.
Step 4. Stir your coffee.
Fill in the flowchart symbols with the Start
steps based on the give algorithms.
Step 1. Start
Pour the hot water in a
Step 2. Add two teaspoons of coffee mug.
in a mug.
Step 3. Pour the hot water in a mug.
Stir your coffee.
Step 4. Stir your coffee.
End
Start
Example:
Read the two sides of rectangle
and calculate its area. Input W, L
End
Start
Example:
Convert the length in feet to
centimeter. Input Lft
Algorithm:
Lcm= Lft*30.48
Step 1. Input Lft
Step 2. Lcm=Lft x30.48
Step 3. Print Lcm Print Lcm
End
Example:
Fill in the flowchart with the correct sequence of
steps based on the algorithm below.
Algorithm:
Step 1. Input a,b,c
Step 2. Average=(a+b+c)/3
Step 3. Output average
Start
Input,a,b,c
Average=(a+b+c)/3
Output Average
End
Example:
Design a flowchart that will compute how many 25 centavos
are there in a five-peso coin.
Algorithm:
Step 1. Coins=5.00
Step 2. Total=5.00/25
Step 3. Print Total
Start
Coins=5.00
Total=5.00/.25
Print Total
End
Sample Answer:
Deciding whether to buy a new phone or not.
Algorithm:
Step 1. Decision to buy a new phone
Step 2. Do I have enough savings to buy the phone?
Step 3. If yes, buy a new one
otherwise
Step 4. Save More
Start
Decision to buy
a new phone
Yes
Buy a new
one End
Example:
Determining if you will be allowed to watch a PG-13 movie.
Algorithm:
Step 1. Start
Step 2. Read age
Step 3. If age is greater that or equal to 13, the person is
allowed to watch Jurrasic Park, or else the person is not
allowed.
Step 4. Stop
Start
Read age
Yes Watch
If age >=13?
Jurrasic Park
No
Person not
allowed End
Example:
Flip the Coin. Jeff and Rey are talking about who will be the
one to pay for their lunch, so they decided to flip a coin. If it
lands on heads, Jeff will pay, and if it does not, Rey will pay.
Algorithm:
Step 1. Flip the coin
Step 2. Is the coin heads?
Step 3. If yes, Jeff pays
else
Step 4. Rey pays
Start
Yes
Is the coin Jeff Pays
heads?
No
Rey Pays
End
Activity:
Create a flowchart and algorithm that shows an expression
using variables. The program asks for the user to enter two
numbers, compute the sum, and display the sum. The
variables num 1, num 2, and sum are used to hold values.
Start
Enter num1
Enter num2
Sum=
num1+num2
Input bs
Input ys
No
Is ys<=2 b=500*ys
Yes
b=300*ys
Paycheck=bs+b Print
Paycheck End
Create a Flowchart
Enter num1
Enter num2
Sum=
num1+num2