You are on page 1of 23

II.

Activity Section
Conditional2 Activity 1
a. Problem
Write a C program that will categorize the grade of a student in
alphabetical form (90-100: A; 80-89: B; 70-79: C; 60-69: D;
Below 60: F).
b. Algorithm
-Input: Enter grade (g)
-Process: Categorize grade (g)
-Output: Display grade category
c. Flowchart
Figure 1. Conditional2 Activity 1 Flowchart
The figure above indicates the process the program must flow.
The program first asks for the grade. This value should be from 0 to 100.
The program will then test out whether the value falls into which
alphabetical category. After the program determines which of the
following categories is the grade considered into, the program stops.
d. Source Code

e. Program Output
Conditional2 Activity 2

a. Problem
Write a C program that determines the equivalent color assigned
to the letter.
b. Algorithm
-Input: Enter letter (let)
-Process: Assign color to letter (let)
-Output: Display color of chosen letter (let)
c. Flowchart

Figure 2. Conditional2 Activity 2 Flowchart


The program shows the step by step procedure the program
must execute to determine the assigned color corresponding to the
letter. A letter must first be inputted. The program then decides and
checks whether the letter is in one of the conditions. If the letter checks
out, a color will be printed to the output window and the program ends.
If the letter is not found or fits in any of the conditions, the program
will print out “Unknown color” and end the program.

d. Source Code

e. Program Output
Conditional2 Activity 3

a. Problem
Make a C program that will determine the year level of the student.
b. Algorithm
-Input: Enter year level (n)
-Process: Assign name to year level (n)
-Output: Display name of year level (n)
c. Flowchart

Figure 3. Conditional Activity 3 Flowchart


The figure above shows the method of steps the program must
follow to determine the year level. The program first asks for an input
for the year level. The program then decides which of the cases this
value follows through. The year level equivalent will then be outputted
if and only if the inputted value is interpreted to be true; otherwise, the
program prints “Out of school”. The program then halts.
d. Source Code

e. Program Output
III. Supplementary Section
Conditional2 Supplementary 1
a. Supplementary Worded Problem
Write a C program that will take in the order of the user for pizza
given the flavor of the pizza, size of the pizza, and the age of the
user for discount purposes.

b. Supplementary Program Algorithm


Input: Enter pizza flavor (d), size of pizza(b), additional toppings
(M), and quantity of pizzas(d), age (e)
Process: Store order and compute for total price of order (R)
Output: Display order and amount to pay (R)
c. Supplementary Program Flowchart
Figure 4. Conditional2 Supplementary 1 Flowchart
The figure above showcases the process of obtaining the
complete order of pizza and the price of the order. The program
involves numerous inputs, in this case, asks for the pizza flavor, size,
toppings, amount of pizzas, and age of the user. The program starts
with asking for the pizza flavor. Afterwards the size of the pizza, the
toppings, the amount of pizzas to order, and the age are asked
sequentially. The program ends with printing the information gathered
above to the output window and the price of the order.
d. Supplementary Source Code
e. Supplementary Program Output
IV. Program Observation and Conclusion
The first activity makes use of the else-if statement. In this program, the else-
if statement is explored using a grade equivalent category scheme. In this type of
conditional statement, there can exist several if statements in the form of else-if. As
with the if-else statement, if all the else-if statements were found to be false, the
program will proceed with the else statement. An else-if statement is essentially just
an if statement.
The second activity also makes use of the else-if statement. In this case, the
program explores the use of the character data type in the condition of the else-if
statements. It can be noted that the capital and small letters of the character are
both written in the conditional statement. The presence of either of the two in the
inputted value and in the conditional statement will indicate that the condition has
been met. This signals the printing of a value or output in the output window.
The third activity makes use of the switch statement. As seen in the program,
the switch statement makes use of cases. In the switch statement, the condition is
dissimilar to the else-if statement. The conditions here are numerical based (case 1,
case 2, case 3) and sequential. The concept is still similar with else-if statements; the
program will run each switch statement until the condition is met else the default
statement is run through.
The supplementary activity extensively makes use of the switch and else if
statements. For every output required by the program, a conditional statement was
executed. Each statement gives a different output from the others. Numerous
varying outputs can arise for every run of the program. The program also makes use
of arithmetic in the case of price and discount computing.
Experiment 3 aims to explore the else-if and switch statements. This
experiment is a continuation of experiment 2, wherein conditional statements were
also the general topic. The concepts of else-if and switch statements are very much
similar with if-else statements. The functionality and end goal of these statements
are all akin to each other. These only differ in variable testing.

You might also like