Activity
CC2-1-Fundamentals of Programming/CC2-Computer Programming 1
Module 14 – Array and String II
Background
The lesson discussed about C-String an array-based and null-terminated implementation of string. C-string is an
array of characters with the character null '\0'as the last element. Just like other array, each element (characters
that constitute the string) in C-string can be accessed and manipulated using index or subscript operator [].
C++ programming language has also another implementation of string which is the string class. Methods of class
string can be used to manipulate the string values. These methods can be utilized by including in your code the
string library as follows:
#include <string>
Task
Now perform the following tasks below:
Task A
Write a program that prompts the user to input a string and outputs the string in uppercase letters. You must use a
character array to store the string.
Task B
Write a program that prompts the user to input as string, then replace each vowel the exists on that string with the
character '*'. You must use character array in implementing your solution.
Task C
Write a program that prompts the user to input a string, then convert each lowercase character in it to uppercase,
and all uppercase character to lowercase. You must use character array in implementing your solution.
Task D
Write a program that prompts the user to input 2 strings then output the string with greater value. Use character
strings in implementing your solution.
Sample Output
Sample Program Run for Task A
Enter a string: hello world!, welcome to programming
HELLO WORLD!, WELCOME TO PROGRAMMING
Sample Program Run for Task B
Enter a string: 'A' is for "Apple", 'a' - 'a' ... "apple".
'*' *s f*r "*ppl*", '*' - '*' ... "*ppl*".
Sample Program Run for Task C
Enter a string: Computer PROGRAMMING is Fun!
cOMPUTER programming IS fUN!
No, it’s not!
Sample Program Runs for Task D
Task D Sample Run 1
Enter first string: hello
Enter second string: Hello
hello
Task D Sample Run 2
Enter first string: hello
Enter second string: hi
hi
Submission
a) This activity must be accomplished individually.
b) You can use any C++ IDE installed in your devices or you can utilize online C++ editors/IDE in making
this output.
c) It is the source file (.cpp) of your program which you will submit to our Learning Management System.
d) Try to solve the problems without on your own without the aid of anyone or anything.