Question: 1 . Write a C + + program that does the following: a . Create a C + + file with the name problem 1

1. Write a C++ program that does the following:
a. Create a C++ file with the name problem1.cpp.
b. Write the function fillCharArray, which has a two-dimensional character array and two integers as parameters filling each element of the array parameter with a randomly chosen lower case letter.
c. Write the function randomChar,which returns a randomly generated lowercase character. Generate an integer randomly from the range of 97 to 122 and cast it as a char to obtain the random lowercase letter. This function does not require any parameters.
d. Write the function printArray, which has a two-dimensional character array and two integers as parameters printing the elements of the character array parameter separated by spaces, with each row printed on a separate line.
e. Write the function vowelsPerRow, which has a two-dimensional character array, a one-dimensional integer array and two integers as parameters counting the number of vowels in each row of the character array. The count for row i is stored in element i of the integer array.
f. Write the function vowelsPerCol, which has a two-dimensional character array, a one-dimensional integer array and two integers as parameters counting the number of vowels in each column of the character array. The count for column i is stored in element i of the integer array.
g. Write the function printVowelRows, which takes a one-dimensional integer array and an integer as parameters, printing the vowel count for rows with a positive count.
h. Write the function printVowelCols, which takes a one-dimensional integer array and an integer as parameters, printing the vowel count for columns with a positive count.
i. Write the main function that does the following:
i. Declare a 2 x 4 character array.
ii. Declare an integer array of size 2.
iii. Declare an integer array of size 4.
iv. Call the srand function to seed the random number generator using time(0).
v. Call the function fillCharArray, passing into it the character array, 2, and 4.
vi. Call the function printArray, passing into it the character array, 2, and 4.
vii. Call the function vowelsPerRow, passing into it the character array, the integer array of size 2,2, and 4.
viii. Call the function vowelsPerCol, passing into it the character array, the integer array of size 4,2, and 4.
ix. Call the function printVowelRows, passing into it the integer array of size 2, and 2.
x. Call the function printVowelCols, passing into it the integer array of size 4, and 4.
Sample run of the program:
v j x l
v e n u
Row 1 contains 2 vowels.
Col 1 contains 1 vowel.
Col 3 contains 1 vowel.
Another sample run of the program:
j a x l
o i n q
Row 0 contains 1 vowel.
Row 1 contains 2 vowels.
Col 0 contains 1 vowel.
Col 1 contains 2 vowels.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!