You are on page 1of 19

II.

Activity Section
Looping Activity 1

a. Problem
Write a program that will presents the digits 1, 2, 3, 4, 5
sequentially using the for loop.
b. Algorithm
-Input: -----
-Process: increases the value by 1 (starts with 1)
-Output: displays 1 to 5
c. Flowchart

Figure 1. Looping Activity 1 Flowchart


The figure above shows the procedure of the program. The
program starts with noting the variable n is equal to 1. Since the digit is
less than 5, the program prints this value to the screen. The program
then loops and adds one to this number until the statement n<=5 is
disproven. Afterwards, the program comes to a stop.
d. Source Code

e. Program Output
Looping Activity 2

a. Problem
Write a C program shows the digits 5, 4, 3, 2, and 1 sequentially
using the for loop.
b. Algorithm
-Input: ----
-Process: decreases the value by 1 (starts with 5)
-Output: displays 5 to 1
c. Flowchart

Figure 2. Looping Activity 2 Flowchart

The figure above indicates the procedure the program must follow.
The program starts with noting the variable n is equal to 5. Since the digit is
more than 1, the program prints this value to the screen. The program then
loops and decreases this number by one until the statement n>=1 is
disproven. Afterwards, the program stops.
d. Source Code

e. Program Output
Looping Activity 3

a. Problem
Write a C program that determines the sum of the sequential digits
1, 2, 3, 4, and 5 using for loop.
b. Algorithm
-Input: -----
-Process: increases the value by 1 (starts with 1)
-Output: displays 1 to 5 and the sum of these digits
c. Flowchart

Figure 3. Looping Activity 3 Flowchart


The program shows the step by step procedure the program
must execute. The program first notes that i is equal to one. The
program then prints this to the output window and adds this number
to the sum. The program loops and if i<=5 is disproven, the program
outputs the sum of the digits. The program then comes to a stop.

d. Source Code

e. Program Output
Looping Activity 4

a. Problem
Make a C program that makes use of the while loop which
sequentially shows the following numbers: 1, 2, 3, 4, and 5.
b. Algorithm
-Input: --
-Process: increases the value by 1 (starts with 1)
-Output: displays 1 to 5
c. Flowchart

Figure 4. Looping Activity 4 Flowchart


The figure above shows the method the program must follow to
make use of the while loop. The program notes that n is equal to 1. The
program then notes that a loop will occur as long as the statement n<=5
is satisfied. In this loop, the program prints n. When the statement n<=5
is proven false, the program stops.
d. Source Code

e. Program Output
Looping Activity 5

a. Problem
Make a C program that will generate the digits 1, 2, 3, 4, and 5
sequentially using the do-while loop.
b. Algorithm
-Input: -----
-Process: increases the value by 1 (starts with 1)
-Output: displays 1 to 5
c. Flowchart

Figure 5. Looping Activity 5 Flowchart


The figure above presents the procedure the program must
execute. The program starts with noting n=1. The program then
outputs n to the window. The variable n is then increased by one and if
n<=5, a loop occurs. If n is seen to be n>=5, the program stops.
d. Source Code

e. Program Output
Looping Activity 6

a. Problem
Make a C program that will determine the summation of 1, 2, 3, 4,
and 5 using the while loop.
b. Algorithm
-Input: ----
-Process: increases the value by 1 (starts with 1)
-Output: displays 1 to 5 and the sum of these digits
c. Flowchart

Figure 6. Looping Activity 6 Flowchart


The figure above indicates the methods the program must follow
to obtain the wanted output of the program. The program starts with
indicating i=1. The program then notes whether the value of i as not
greater than equal to 5. If the value of i is less than or equal to 5, a loop
occurs wherein this value is outputted to the window and the sum of
these values is noted. If the value is seen to be more than 5, the
program outputs the sum of the values and the program stops.
d. Source Code

e. Program Output
Looping Activity 7

a. Problem
Make a C program that will determine the summation of 1, 2, 3, 4,
and 5 using a do-while loop.
b. Algorithm
-Input: --
-Process: increases the value by 1 (starts with 1)
-Output: displays 1 to 5 and the sum of these digits
c. Flowchart

Figure7. Looping Activity 7 Flowchart


The figure above shows the methods used by the program to find
the summation of 1 to 5 using the do-while loop. The program starts
with giving i an initial value of 1. The program then outputs this value
to the window and notes the sum of this. The variable is then
determined whether it is less than or equal to 5 such that a value of less
than or equal to 5 indicates a loop in the program. If proven otherwise,
the program outputs the sum of the values and comes to a stop.
d. Source Code

e. Program Output
III. Supplementary Section
Looping Supplementary 1
a. Supplementary Worded Problem
Write a C program that will determine the even numbers from ten
random inputted numbers and display the summation of these
even numbers.

b. Supplementary Program Algorithm


-Input: Enter ten numbers
-Process: Determine the even numbers, compute for the
summation the even numbers, and get the average of all even
numbers
-Output: Display the ten numbers and the average of all even
numbers
c. Supplementary Program Flowchart

Figure 6. Basic Conditional Supplementary 1 Flowchart


The figure above presents the methods utilized by the program
to execute the goal of this program, which is to compute for the sum
of all even numbers. The input for this program is ten numbers. The
process of the code is to determine the even numbers. The program
then obtains the summation of these even numbers. The program
comes to a stop after this step.
d. Supplementary Source Code

e. Supplementary Program Output


IV. Program Observation and Conclusion
The first activity mainly shows the use of the for loop statement. The program
aims to generate a sequence, which is what loops are usually used for. Since this
code is the introductory lesson for looping, the code is fairly easy and makes use of
the least complicated and most straightforward looping statement. The program is
expected to create an increasing sequence. This sequence starts with 1 and ends
with 5; however, the perimeter set in this program can still be altered in other
programs.
The second activity also utilizes the for loop statement. It should be noted
that instead an incremental sequence, a decremental sequence must be created.
The code is also fairly easy. The goal of the activity is to only show that it is possible
to create a decremental loop. The sequence starts with 5 in the case of this lesson
and ends with 1.
The third activity utilizes the for loop again; however, arithmetic is added in
this lesson. The program is expected to add all the digits used in the loop. In this
case, the program is expected to create a incremental sequence of 1 to 5. The
program must then add these digits by creating a code within the loop to store the
current value of the digit. The program then outputs the summation of this digits
after the loop stops.
The fourth activity is similar to the first activity; however, the program is
expected to make use of the while loop. The program also uses an incremental
sequential method. The program is also expected to showcase a sequence of 1 to 5
in the end. The only difference of this activity with the first is the use of the while
loop instead of the for loop. The use of whichever loop does not matter as the same
output will always be created.
The fifth activity is similar to the first and fourth activity. The only difference
in this case is that the do while loop is utilized. The program outcomes are also the
same. The sequence of 1 to 5 is expected to be created. The structure of the
program is the only thing that differs to this and to that of the first and fourth
activity.
The sixth activity is similar to the third activity. However, the while loop is
utilized in this lesson. The summation of the digits is also expected to be gotten. In
the case of the while loop, the program separates the initialization, condition, and
loop control. In the case of the for loop, all three are within the same area and this
separation is the only thing that differs the while loop and for loop.
The seventh activity makes use of the do while loop. The activity is also similar
with the third and sixth activity. An incremental method and the summation must
also be utilized. The program is expected to recreate the outcome of the third and
sixth activity while using a different structure of the loop. In the case of the do while
loop, the program is expected to create the statement and looping control first and
then the condition.
The supplementary activity aims to make use of any of the three looping
statements, for, while, and do while loops. In this case the for loop is utilized.
However, it should be noted that using the while and do while loops will still render
the same result as the for loop. Arithmetic is yet again seen in this program which
was also present in the previous experiments. The program also makes use of if-else
statements, which was the topic of the experiment prior to this.
Experiment four mainly deals with looping statements. As seen in the
examples, there are three types of looping statements. These are the for loop, while
loop, and do while loop. The difference among these loops are the placing of the
initialization, condition, and looping control. The program outcomes stay as is
whether whichever looping statement is utilized.

You might also like