Professional Documents
Culture Documents
1. Write a program that will accept an integer and execute one of the following based on the
input using IF statements:
a. If 0, display only “Hello World”.
b. If 1, display only “I am Groot”.
c. If 2, display only “To the Top”.
d. If 3, display only “Where is the horizon”.
e. If 4, display only “I do not know”.
f. If none of the above, display only “Yeah, I will.”
START
Declare a
Accept a
false true
a=0
false true
a=4
END
Pseudocode:
1. Declare a
2. Input a
3. IF a=0 then
Output “Hello World”
Else IF a=1 then
Output “I am Groot”
Else IF a=2 then
Output “To the top”
Else IF a=3 then
Output “Where is the horizon
Else IF a=4 then
Output “I do now know”
Else
Output “Yeah, I will”.
End
4. End
2. Write a program that will accept an integer and execute one of the following based on the
input using SWITCH statements:
a. If 0, display only “Hello World”.
b. If 1, display only “I am good”.
c. If 2, display only “To the Top”.
d. If 3, display only “Where is the horizon”.
e. If 4, display only “I do not know”.
f. If none of the above, display only “Yeah, I will.”
START
Declare a
Accept a
Switch a
true
Case
Display “Hello World”
0
false
false
Case true
Display “To the top”
2
false
false
false
END
Pseudocode:
1. Declare a
2. Input a
3. Switch a
4. Case 0 then
Output “Hello World”
Break
5. Case 1 then
Output “I am good”
Break
6. Case 2 then
Output “To the top”
Break
7. Case 3 then
Output “Where is the horizon”
Break
8. Case 4 then
Output “I do not know”
Break
9. Default
Output “Yeah, I will.”
10. End
3. Write a program that will divide the two floating points entered by the user (first number
entered divided by the second number entered). Make sure your application handles all
possible scenarios with floating points.
START
Declare x,y
Accept x
Accept y
false true
y=0
End
Pseudocode:
1. Declare x,y
2. Input x
3. Input y
4. If y = 0 then
If x = 0 then
Output “0/0 is undefined, its limit is indeterminate in form”.
Else
Output “Any number divided by zero is undefined. Its limit can be positive or negative infinity”.
End
Else
Output “The quotient of the two number is” + x/y + “.”
End
5. End
4. What can you conclude from this activity?
Therefore I conclude that in this activity, the two conditionals IFs and SWITCHEs are
useful when doing coding as it makes the code systematic especially if I’ll encounter
problems with different statements.