Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

C++ programming 1 of 3 Lab 13 Work You always create a separate C++ file for each program you write in the lab. 1. Write

C++ programming

image text in transcribed
1 of 3 Lab 13 Work You always create a separate C++ file for each program you write in the lab. 1. Write a C++ program that does the following: a. Create a C++ file with the name problem1.epp. 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. Write the function randomChar, which returns a nich 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. 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 el in element i of the integer array. Write the function vowelsPerCol, which has a two-dimensional character array, a one-dimension array and two integers as parameters counting the number of vowels in each column of the character array. The count for column i is store mm is stored in element i of the integer array. 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. 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. Write the main function that does the following: Declare a 2 x 4 character array. Declare an integer array of size 2 Declare an integer array of size 4. iv. Call the srand function to seed the random number generator using time(0). Call the function fill CharArray, passing into it the character array, 2, and 4 vii. Call the function printArray, passing into it the character array, 2, and 4. Call the function vowelsPerRow, passing into it the character array, the integer array of size 2, vili, Call the function vowelsPerCol, passing into it the character array, the integer array of size 4, 2, ix. Call the function print VowelRows, passing into it the integer array of size 2, and 2 Call the function print VowelCols, passing into it the integer array of size 4, and 4. Sample run of the program: venu Row 1 contains 2 vowels. Col 1 contains 1 vowel. Col 3 contains 1 vowel. Another sample run of the program: oniq Row 0 contains 1 vowel. Row 1 contains 2 vowels. Col 0 contains 1 vowel. Col 2 contains 2 vowels. 2. Write a C++ program that does the following: Create a C++ file with the name problem2.epp. Write the function swapFirstLetters, which takes two strings as parameters, permanently swapping the first character of the two strings. 1. Write the function longestString, which takes two strings as parameters, printing the longer string and returning the length of the longer string. If bo string. If both strings are of equal length, then use either string. m. Write the function repeatHello, which takes an integer as a parameter, printing the string "Hello" the number of times equal to the parameter. Write the main function that does the following: Prompt the user for their first name and last name. Call the function swapFirstLetters, passing into it those two strings. ili, Print the two modified names. Call the function longestString, passing into it those two strings. Call the function repeatHello, passing into it the length returned by longestString. ample run of the program: Please enter your first name: Dave Please enter your last name: Miller Your new first name is Mave Your new last name is Diller Diller is the longest string. HelloHelloHelloHelloHelloHello 3. Write a C++ program that does the following: a. Create a C++ file with the name problem3.cpp. Write the function bookEndString, which has a string s and an integer r as parameters, permanently modifying the string s. If the first and last letters of the string are the same, then add r copies of that lette to the beginning and ending of the string. Otherwise, add r Z's to the beginning and ending of the string. A ist-1-prod-fleet02-xythos.content.blackboardcdn.com 2 of 3 2. Write a C++ progr j. Create a C++ file with the name problem2.epp. k. Write the function swapFirstLetters, which takes two strings as parameters, permanently swapping the first character of the two strings. 1. Write the function longestString, which takes two strings as parameters, printing the longer string and wherethe the engin of the longer string. If both strings are of equal length, then use either string. m. Write the function repeatHello, which takes an integer as a parameter, printing the string "Hello" the met the user for their first name and last Call the function swap FirstLetters, passing into it those two strings. Call the function longestString. the function repeat Hello, passing into it the length returned by longestString. Sample run of the program: Please enter your first name: Dave Your new free games name: Miller HelloHelloHelloHelloHelloHello . Write a C++ program that does the following: b. Write the function bookEndString, which has a string s and an integer r as parameters, permanently modifying the string s. If the first and last letters of the string its of the string are the same, then add r copies of that letter There washing and ending of the string. Otherwise, add r Z's to the beginning and ending of the string. on that does the following: Prompt the user for a string containing at least 3 letters, validating the input until the user enters Prompt the user for a positive integer, validating the input until the user enters a positive integer. iii. Call the function book EndString passing into it the string and the integer. Simpler word with at least three letters: hi valid input! Enter a word with at least three letters: hello Enter a number greater than 0: 0 nter a number greater me modified word is: ZZZ Enter a word with at least three letters: shoes 4. Write a C++ program that does the following: a. Create a C++ file with the name problem4.epp. b. Write the function readInput, which has a one-dimensional array and an integer as parameters, prompting the user for strings to fill the one-dimensional array. Write the function getPrefixes, which has two one-dimensional arrays and an integer as parameters, copying the first three characters (as a string) of each element of the first array parameter to the corresponding element of the second array parameter. Write the function concatenateStrings, which has a one-dimensional array and an integer as parameters returning the concatenated string from all the elements of the array parameter. . Write the main function that does the following: Declare two string arrays called words and prefixes, each having size 5 ini. Call the function readInput, passing into it the array words and 5. iv . Call the function getPrefixes, passing into it the array words, the array prefixes, and 5. Call the function concatenateStrings, passing into it the array prefixes and 5, assigning its return Print the concatenate Sample run of the program: Enter 5 words: bird cat dog horse ox Concatenated string is bircatdoghorox Lab Work Submission: . You can continue to work on this lab after our lab class, on your own, at home. your to work via Bla ackboard on or before: Sunday, May 12, 2024. This is the only accepted submission method! Once you submit your assignment you will not be able to resubmit it! Make absolutely sure the C++ files you want to submit are the C++ files you want graded. You will not be able to submit your lab work under any circumstances once Lab 13 Work disappears at 12:00 a.m. on Monday, May 13, 2024. There will be NO exceptions to these rules! To submit your lab work, upload the 5 C++ files you did for this lab (with .epp extension) to the Lab 13 Work assignment in the Lab Work tab Then, make sure you click the Submit button to submit your lab work he lab work is worth a total of 9 points based only o your program does NOT compile succes compile successfully, then the grade for the lab is zero. lab is zero. 2. If your program produces runtime errors or does NOT produce the expected output, then the grade for the . If the program compiles, runs, and produces the expected output, then the grade is computed as follows: a. 8 points - the program compiles, runs, and produces the expected output ht - proper indenta

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Mobile Communications

Authors: Jochen Schiller

2nd edition

978-0321123817, 321123816, 978-8131724262

More Books

Students also viewed these Programming questions

Question

Q.1. what is constitution? Q.2. key of the constitution?

Answered: 1 week ago

Question

Q.1. what is meant by federal system?

Answered: 1 week ago