Professional Documents
Culture Documents
Figure 1. String Activity 1 Flowchart
Figure 1. String Activity 1 Flowchart
Activity Section
String Activity 1
a. Problem
Write a C program that prints out the name of the school while
using the concepts in string.
b. Algorithm
Input: Enter school name (sname)
Process: -------
Output: Display school name(sname)
c. Flowchart
e. Program Output
String Activity 2
a. Problem
Write a C program that measure the length of the string of the
inputted favorite food of the user and two other favorite foods
(chicken adobo and chicken adobo written in single characters).
b. Algorithm
Input: Enter favorite food(favoritefood3)
Process: Measure length of strings favoritefood1, favoritefood2, and
favoritefood3.
Output: Display length of the strings favoritefood1, favoritefood2, and
favoritefood3.
c. Flowchart
Figure 2. String Activity 2 Flowchart
The figure indicated above shows the pathway the program must
follow to conduct the objectives. The program starts with the
declaration of variables used. This is followed by obtaining input from
the user, stored in the variable favoritefood3. The process in this
program involves the counting of the length of the strings
favoritefood1, favoritefood2, and favoritefood3. The program then
displays the data gathered from the process and ends afterwards.
b. Source Code
c. Program Output
String Activity 3
a. Problem
Make a C program that will print out the color of DLSU and the
term De La Salle University in the sequence De La Salle University,
De La Salle University, Green, Green given that a value, Ateneo de
University, is contained in the second variable. The program should
make use of strings and the strcpy() function.
b. Algorithm
Input: Enter the La Salle color (str4)
Process: Copy str1 to str 2 and str4 to str3
Output: Display the values of the strings (str1, str2, str3, str4)
c. Flowchart
e. Program Output
String Activity 4
a. Problem
Write a C program that concatenates two variables, De La Salle
University and the department the user belongs to (str2).
b. Algorithm
Input: Enter department (str2)
Process: Concatenate str1 and str2
Output: Display str1
c. Flowchart
e. Program Output
String Activity 5
a. Problem
Write a C program that will compare two strings by the amount of
characters. In this case, the first variable (str1) contains the favorite
cartoon character. The second variable (str2) contains the favorite
Marvel hero. The third variable (str3) contains the favorite DC hero,
and the fourth variable contains the favorite cartoon character.
b. Algorithm
Input: Enter favorite cartoon character(str1), favorite Marvel
hero(str2), and favorite DC hero (str3), and favorite cartoon character
(str4)
Process: Compare variables str1 and str2, str1 and str3, str1 and str4.
Output: Display results of the process
c. Flowchart
Figure 5. String Activity 5 Flowchart
The figure indicated above depicts the flow the program must
follow. The program must first ask for the following inputs from the
user: favorite cartoon character (str1), favorite Marvel hero(str2),
favorite DC hero(str3), and favorite cartoon character(str4). The
program stops afterwards.
d. Source Code
e. Program Output
String Activity 6
a. Problem
Write a C program that changes uppercased characters to
lowercased characters and vice versa. The inputted values are
favorite cartoon character in uppercase and favorite Marvel hero in
lowercase.
b. Algorithm
Input: Enter the favorite cartoon character in uppercase(str1) and the
favorite Marvel hero in lowercase(str2)
Process: Convert str1 to all lowercases and str2 to all uppercases
Output: Display the new values of str1 and str2
c. Flowchart
Figure 6. String Activity 6 Flowchart
The figure indicated above depicts the flow of the program to
execute the objectives of the program properly. The program first asks
for the favorite cartoon character of the user (str1) in uppercase and
then the favorite Marvel hero of the user (str2) in lowercase. The
program then modifies str1 to turn the characters in all lowercase
letters and outputs the new value to the output screen. The program
also modifies str2 to transform the characters to uppercases and then
outputs this value to the output screen. The program stops afterwards.
d. Source Code
e. Program Output
III. Supplementary Section
String Supplementary 1
a. Supplementary Worded Problem
Write a C program that transforms a regular singular noun to its
plural form and to show the plural form of an irregular noun. The
program must contain 10 irregular nouns.
b. Supplementary Program Algorithm
Input: Enter a singular noun (n) and a number between 1 to 10 (a)
Process: Add an s to the variable n. Manipulate characters in the
inputted value (a)
to transform the singular noun to its plural form
Output: Display n and value in the variable a
c. Supplementary Program Flowchart
Figure 7. String Supplementary 1 Flowchart
The figure above shows the pathway that must be followed in
writing the program. The program starts with asking for an input of a
singular noun denoted by the variable n. The program makes use the
function strcat() to transform the singular noun to its plural form. The
program then asks for a number between 1 to 10. The program must
execute the flow written in whatever value inputted by the user and
ends the program afterwards.
e. Supplementary Source Code
f. Supplementary Program Output