01 LABORATORY EXERCISE 1
Algorithms and
Flowchart
MAR JONES C. BASWEL
BIT- AT 2BG1
SEQUENTIAL:
A. DESIGN AN ALGORITHM AND FLOWCHARTS THAT
CONVERT CELSIUS TO FAHRENHEIT. USE THE FORMULA:
F = C X (1.8 + 32)
B. DESIGN AN ALGORITHM AND FLOWCHART THAT
COMPUTES THE WAGE OF A PART-TIME EMPLOYEE
USING THE FORMULA: WAGE = HOURLY RATE X
NUMBER OF HOURS.
ALGORITHM (a):
1. Define the variables: (Let F be Fahrenheit and let
C be Celsius).
2. Identify the value to be used: F=0°, C=0°
3. Input the value of C.
4. Compute the value of F
5. Output of Fahrenheit
Flowchart: Start
F=0
C=0
(1.8+32)
prod=0
C* (1.8+32)
F= C * (1.8 + 32
Output of F
End
ALGORITHM (b):
1. Define the variables: Let W be the wage.
2. Identify the value to be used: W=0.
3. Input the value of W.
4. Compute the value of W.
5. Output of Wage.
Flowchart: Start
W=0
W
Hourly rate
Num of hrs
F= C * (1.8 + 32
Output of Wage
End
SELECTION:
A. DESIGN AN ALGORITHM AND FLOWCHART THAT DETERMINES IF A
GIVEN NUMBER IS ODD OR EVEN.
B. DESIGN AN ALGORITHM AND FLOWCHART THAT WILL INPUT THE
HEIGHT (H) AND BASE(B)OF THE RIGHT TRIANGLEAND WILL COMPUTE
FOR THE FOLLOWING:
HYPOTENUSE OF THE TRIANGLE
PRINT THE PERIMETER OF THE TRIANGLE IF THE HYPOTENUSE
EXCEEDS 10 CM.
PRINT THE AREAOF THE TRIANGLE IF THE HYPOTENUSE IS EQUAL
TO 10 CM.
“IT’S ALRIGHT”IF THE HYPOTENUSE IF LESS THAN 10 CM.
ALGORITHM (a):
1. Define the variables: Let E be the Even and O be the odd.
2. Initialize the variable to be used: O=0, E=0
3. Input the value of E and O
4. Test if the values are divisible by 2 or not.
5. If the values are visible by 2 then output “even”. if not,
then output “odd”.
Flowchart: Start
O=0
E=0
O, E
Value of O If even divisible
and E by two ouput even
If not divisible
by 2 output ‘odd’
End
ALGORITHM (b):
1. Define the variables: Let H be the height, let B be the base.
2. Identify the variable to be used: H=0, B=0
3. Input the value of H and B
4. Evaluate the value of hypotenuse if it exceeds or equals 10cm
and if it is less than 10cm.
5. The print perimeter of a triangle if hypotenuse exceeds 10cm,
print area of a triangle is equal to 10cm, and print “it’s all right” if
less than 10cm
Flowchart: Start
H=O
B=0
H,B
Print “Area of
triangle if hypotenuse Hypotenuse of
Print “Perimeter of
Equals 10m triangle triangle if hypotenuse
exceed 10m
Print “it’s alright” i
if less than 10cm
End
REPETITION:
A. DESIGN AN ALGORITHM AND FLOWCHART THAT WILL
COMPUTE FOR THE SUM OF ALL EVEN NUMBERS
AMONG THE TEN(10)INPUTTED NUMBERS.
B. DESIGN AN ALGORITHM AND FLOWCHART THAT WILL
DISPLAY THE NATURAL NUMBERS FROM 10 TO 1.
ALGORITHM (a):
1. Define the variable: (let x be the counter)
2. Intialize the x=0
3. Let the even numbers be (a,b,c,d,e)
4. Calculate the sum of a,b,c,d,e
5. Increase (x=x+a)+(b)+(c)+(d)+(e)
6. end
Start
Flowchart:
X=0
A=2
B=4
C=6
D=8
e=10
x+c X,a,b,c,d,e x+b
x+e x+d
x= x+a
Sum of all
even numbers
End
ALGORITHM (b):
1. Define the variables: Let N be the counter.
2. Let the counter be: N=10
3. Test the value of N. If N >1, print “hello”, or stop.
4. Increment N (N=N+1)
5. Repeat.
Flowchart: Start
N =10
PRESS 'W'
N+1
If N=10
End