0% found this document useful (0 votes)
9 views11 pages

wfaf

The document outlines an exercise for students at the Polytechnic University of the Philippines focused on algorithms, pseudocode, flowcharting, and coding. It includes objectives, background information on algorithms, and specific activities requiring the creation of algorithms, pseudocode, and flowcharts for various programming tasks. Additionally, it discusses the importance of these skills in problem-solving and programming, along with reflections on the learning experience.

Uploaded by

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

wfaf

The document outlines an exercise for students at the Polytechnic University of the Philippines focused on algorithms, pseudocode, flowcharting, and coding. It includes objectives, background information on algorithms, and specific activities requiring the creation of algorithms, pseudocode, and flowcharts for various programming tasks. Additionally, it discusses the importance of these skills in problem-solving and programming, along with reflections on the learning experience.

Uploaded by

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

POLYTECHNIC UNIVERSITY OF THE PHILIPPINES

COLLEGE OF ENGINEERING

CoE DEPARTMENT

(Computer Programming)

EXERCISE

3
ALGORITHM, PSEUDOCODE, FLOWCHARTING,
& CODING

KYLE ASHLY D. CAUSE

BSCE 1-5
APRIL 1, 2024
I. OBJECTIVES
At the end of this exercise, students must be able to:

a) Define what is an algorithm


b) Know how to express algorithms using pseudo code, flowcharts, and programming
languages

II. BACKGROUND INFORMATION


Algorithm is the step-by-step sequence of instructions that describe how the data is to be
processed to produce the desired output

Algorithm can be expressed using the following:


 Natural Languages
 Pseudocode
 Flowcharts
 Programming Languages

Pseudocode is a program design technique that uses English words. Pseudocode cannot
be compiled nor executed, and there are no real formatting or syntax rules.

Flowchart is a graphical representation of an algorithm.

III. LABORATORY ACTIVITY


Write the algorithm, provide the pseudo code, and draw the flowchart of the following
program specifications

ACTIVITY 1.1: Converting Length in Feet to Centimeter

Write an algorithm, pseudo code and draw a flowchart to convert the length in feet to centimeter.

Algorithm:

1.Start
2.Input the length in feet (feet)
3.Convert feet to centimeters using the conversion factor: 1 foot = 30.48 centimeters
4.Calculate centimeters = feet * 30.48
5.Output the length in centimeters
6.Stop
Pseudo code:

1. Start
2. Input feet
3. centimeters = feet * 30.48
4. Output centimeters
5. Stop

Flowchart:

ACTIVITY 1.2: Calculating area of a rectangle


Write an algorithm, pseudo code and draw a flowchart that will read the two sides of a rectangle
and calculate its area.

Algorithm

1. Start
2. Input the length of the rectangle (length)
3. Input the width of the rectangle (width)
4. Calculate the area of the rectangle: area = length * width
5. Output the area of the rectangle
6. Stop

Pseudo code:

1. Start
2. Input Length
3. Input width
4. Area = length * width
5. Output area
6. Stop
Flowchart:
1. Create a pseudo code, algorithm, and flowchart together with a program that
computes a taxi passenger's fare. The 1st four kilometers is Php 40.00 and the
succeeding kilometer is Php 10.00.

ALGORITH:
1. Start
2. Input the distance traveled in kilometers (distance)
3. Initialize total fare (fare) = 0
4. 4. If distance <=4:
 fare = Php 40.00
5. If distance > 4:
 fare + 40.00 + (distance – 4) * 10.00
6. Output the total fare
7. Stop

PSEUDO CODE:
1. Start
2. Input distance
3. Fare = 0
4. If distance < = 4:
 fare = 40.00
5. If distance > 4:
 Fare = 40.00 + (distance – 4) * 10.00
6. Output fare
7. Stop

PYTHON PRGRAM

def calculate_taxi_fare(distance):
fare = 0
if distance <= 4:
fare = 40.00
else:
fare = 40.00 + (distance - 4) * 10.00
return fare

# Input distance traveled from the user


distance = float(input("Enter the distance traveled in kilometers: "))
total_fare = calculate_taxi_fare(distance)
print("Total fare: Php", total_fare)
FLOWCHART
2. Create a pseudo code, algorithm, and flowchart together with a program that add,
subtract, multiply, and divide two numbers.

ALGORITHM:
1. Start
2. Input two numbers (num1, num2)
3. Perform addition: result_add = num1 + num2
4. Perform subtraction: result_sub = num1 + num2
5. Perform multiplication: result_mul = num1 + num2
6. Perform division: result_div = num1/ num2
7. Output the results of addition, subtraction, multiplication, and division
8. Stop

PSEUDOCODE:
1. Start
2. Input num1
3. Input num2
4. result_add = num1 + num2
5. result_sub = num1 – num2
6. result_mul = num1 * num2
7. result_div = num1/ num2
8. Output result_add, result_sub, result_mul, result_div
9. Stop

PYTHON PRGRAM

def perform_operations(num1, num2):


result_add = num1 + num2
result_sub = num1 - num2
result_mul = num1 * num2
result_div = num1 / num2
return result_add, result_sub, result_mul, result_div

# Input two numbers from the user


num1 = float(input("Enter the first number: "))
num2 = float(input("Enter the second number: "))

addition, subtraction, multiplication, division = perform_operations(num1, num2)

print("Addition:", addition)
print("Subtraction:", subtraction)
print("Multiplication:", multiplication)
print("Division:", division)
FLOWCHART
IV. QUESTION AND ANSWER

1. An algorithm is:
It is the step-by-step sequence of instructions that describe how the data is to be processed to
produce the desired output.

2. In a flowchart, what is an oval used for?


Terminators show that the start and stop points in a process. When used as a Start symbol,
terminators depict a trigger action that sets the process flow into motion.

3. In a flowchart, what is a diamond used for?


It indicates a question or branch in the process flow. Typically, a Decision flowchart shape is
used when there are 2 options (Yes/No).

4. A flowchart is:
It is a diagram showing the flow of instructions in an algorithm.

5. In a flowchart, what is a parallelogram used for?


The Data shape indicates input to and outputs from a process. As such, the shape is more
often referred to as an I/O shape than a Data shape.

6. In a flowchart, what is a rectangle used for?


It shows a process or action step. The most common symbol in both process flowcharts and
business process maps.

REFLECTION:

Writing algorithms, pseudo code, flowcharts, and Python programs has been a valuable
learning experience for me as a student. This experience has improved my ability to solve
problems and expanded my knowledge of logical reasoning and solution architecture.
Developing algorithms has helped me break down complex issues into smaller, more
manageable parts and has encouraged me to tackle difficulties methodically. Because pseudo
code offers an organized depiction of computer logic, it has highlighted the significance of
readability and clarity in coding. The construction of flowcharts has shown to be quite helpful in
improving control flow comprehension, identifying errors, and visualizing program flow.
Programming is iterative, which has highlighted how crucial it is to test, debug, and improve
code in order to get the results you want. Through discussions with peers and instructors, this
technique has fostered collaborative learning, sharpened problem-solving abilities, and fostered
creativity. All things considered, this experience has improved not only my technical skills but
also my analytical thinking, attention to detail, and ability to communicate complicated ideas
effectively and methodically.

You might also like