wfaf
wfaf
COLLEGE OF ENGINEERING
CoE DEPARTMENT
(Computer Programming)
EXERCISE
3
ALGORITHM, PSEUDOCODE, FLOWCHARTING,
& CODING
BSCE 1-5
APRIL 1, 2024
I. OBJECTIVES
At the end of this exercise, students must be able to:
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.
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:
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
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
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.
4. A flowchart is:
It is a diagram showing the flow of instructions in an algorithm.
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.