Question: Strings (20 pts) Assign the second character of the string str to a char variable ch (which has already been declared). (4 pts) Using a

Strings (20 pts)
Assign the second character of the string str to a char variable ch (which has already been declared). (4 pts)
Using a pre-defined String function (discussed in class), assign the first two characters of the string variable str to another string variable called text. (text and str already exist in your program and are in the same scope). (8 pts)
Suppose a String variable called str has already been declared and initialized with a value.Now, suppose that another String variable called str2 has also been declared and populated with some value. Append to str the first six characters stored inside str2. You must use a predefined string function. (Assume all necessary libraries have been included. Also, you can safely assume that the length of str2 is greater than six characters). (8 pts)
2) Arrays with Functions (40 pts)
Declare an array called values that can hold 75 decimal numbers. (3 pts)
Initialize the array with each element getting assigned to it the value corresponding to the current array index multiplied by 1.5. For example, starting from index 0 (first element) the array should contain the following values: 0, 1.5, 3, 4.5, 6, , 111. (10 pts)
Write the prototype of a function called sqrtAvg which takes an array containing decimal values (called arr), as well as a size parameter called size. Make sure that the function cannot modify the original array when it is passed to the function. Also, be sure to choose the proper return type for the function. (4 pts)
Write the function definition of the sqrtAvg function declared above. This function computes the square root of the average value of the array. You can safely assume that all necessary libraries have already been included. (10 pts)
Write the prototype of the function volumeCube that computes and returns the volume of a cube. It takes a single parameter called edgeLength as input. The edge length can be a decimal value or an integer. (3 pts)
Write the definition of the function volumeCube declared above. The formula for calculating the volume of a cube is: V = edgeLength3 (10 pts)
3) Two Dimensional Arrays (30 pts)
Declare a two-dimensional array/matrix called grid containing 4 rows and 6 columns. This matrix will be used to store input of type integer. (5 pts)
Write the code inside main to accept input from the user and assign values to the grid matrix. (10 pts)
Implement/write the definition of a print function called printMatrix. The function prints out the values stored in the array to the screen. Define the necessary parameters as inputs to the function. Remember, the function should work with a 2-D array of any size. Also, make sure the function cannot modify the original array. (10 pts)
Call printMatrix from inside main to print out the contents of grid (5 pts)
(in C++. write everything in one program please)

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 Databases Questions!