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

Algorithm and Flowchart

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

Algorithm and Flowchart

Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 37

Writing 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

- To be a good programmer, you must follow good


problem-solving techniques.
PROBLEM ANALYSIS ALGORITHM CODING COMPILER LINKER EXECUTION OUTPUT

LIBRARY
HUMAN
010101010
INTRUCTIONS
PROBLEM 01101010 SOLVE
PROGRAM
001010101
CODE

Human Language Machine Laguage


• Identify the problem
• Analyze it to identify a possible solution
• The solution will then be written in an algorithm
top itemize the step-by-step instruction
• The process where instructions or source codes
are entered through a programming language
called coding
• Library is a collection of resources routines used
by computer programs
•When the compiler encounters the syntax
errors, the code will be reviewed
•If the compiling is successful, the linker
combines one or more libraries or object
files to produce an executable file
•Will then process the code for execution to
produce the desired output.
Algorithm- is a step-by-step procedure to solve
problems. It makes the whole procedure more efficient as
consistent.
Flowchart- is a diagram representing the logical
sequence in which a combination of steps or operation is
to be performed.
System Used in Flow Charting

Terminator- this is used in declaring the beginning and


the end of the flowchart. Labeled with the word “Start” or
“End”
I

System Used in Flow Charting

Input/Output- this is used if the flowchart needs input


from the user or output from a process
System Used in Flow Charting

Process- this is used to process data, normally


composed of mathematical symbols
System Used in Flow Charting

Decision- If the procedure leads to a comparison which


involves logical or relational operators and questions that
are answered by “Yes” or “No”
System Used in Flow Charting

Flow lines- It specifies the flow of control.


Tips and Tricks:

You can start writing your program through an


algorithm or pseudocode. As a beginner, you do not
need to worry about the programming language
syntax yet. It is important to transcribe your
thoughts into sequential English-like steps or a
flowchart to solve a problem.
A. Identify the correct sequence of instructions or
steps in the tasks by writing the corresponding
letters
1. Creating a reaction paper using a word processing
tool: ___________________
a. Print it
b. Launch the word processing software installed in your
computer.
c. Plug in your computer and turn it on.
d. In a blank document, tyoe the content of your reaction paper.
e. Save it for future reference.
Fill in the flowchart symbols with the steps based on the given
algorithms.

1. Making a coffee in a mug.

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.

1. Making a coffee in a mug. Add two teaspoons of


coffee in a mug.

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

Step 1. Input Width,


Length
A= W x L
step 2. Area=Length x
Width
step 3. Print Area Print A

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

Do I have enough savings


No
to buy the phone? Save More

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

Flip the coin

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

Print Sum End


Example:
Compute for the monthly paycheck of salesperson at a
department store. The employee would receive a bonus
of 300 pesos for each year if he/she has been with the
store for two years or less. If the employee has been with
the store for more than two years, the bonus is 500
pesos for each year.

Calculate the paycheck using the equation value of(paycheck is


equivalent to sum of basesalary (bs) and bonus(b)
Algortihm:
Step 1. Get the base salary.
Step 2. Get the number of years of service.
Step 3. Calculate the bonus using the following formula:
If(yearof service is less than or equal to two)
Bonus= 300* yearofservice
Otherwise
Bonus= 500*yearofservice

Calculate the paycheck using the ff: equation:

Paycheck= base salary+ bonus


Start

Input bs

Input ys

No
Is ys<=2 b=500*ys

Yes

b=300*ys

Paycheck=bs+b Print
Paycheck End
Create a Flowchart

Create a flowchart that will enter a student’s grade and will


show if it is “Passed” or Failed. Any grade lower than 74.5 is
considered failed.
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

Print Sum End


Thank you! ☺

You might also like