Question: Answer one question from each group below. Add the question number and wording before your code. If you need help or clarifications, let me know.

Answer one question from each group below. Add the question number and wording before your code. If you need help or clarifications, let me know.

Group1:

Declare an array named scores of twenty-five elements of type int.

Write a statement that declares an array of chars named streetAddress that contains exactly eighty elements.

Suppose v is an array with 100 int elements. If 100 is assigned to v[100], what happens?

An array of 1000 integers is declared. What is the largest integer that can be used as an index to the array?

Consider the declaration: int v[1]; What is the index of the last element of this array?

Declare an array named a of 10 elements of type int and initialize the elements (starting with the first) to the values 10, 20, ..., 100, respectively.

Declare an array named taxRates of 5 elements of type double and initialize the elements (starting with the first) to the values 0.10, 0.15, 0.21, 0.28, 0.31, respectively.

Write a statement to declare and initialize an array of ints named denominations that contains exactly six elements. Your declaration statement should initialize the elements of the array to the following values: 1, 5, 10, 25, 50, 100. (The value 1 goes into the first element; the value 100 to the last.)

Given the array a, write an expression that refers to the first element of the array.

Given an array a, declared to contain 34 elements, write an expression that refers to the last element of the array.

Assume that the array arr has been declared. In addition, assume that ARR_SIZE has been defined to be an integer that equals the number of elements in arr. Write a statement that assigns the next to last element of the array to the variable x (x has already been declared).

Given that the array monthSales of integers has already been declared and that its elements contain sales data for the 12 months of the year in order (i.e., January, February, etc.), write a statement that writes to standard output the element corresponding to October.

Assume that an array named a, containing exactly five integers has been declared and initialized. Write a single statement that adds ten to the value stored in the first element of the array.

Assume that an array of integers named a that contains exactly five elements has been declared and initialized. Write a single statement that assigns a new value to the first element of the array. This new value should be equal to twice the value stored in the last element of the array. Do not modify any values in the array other than the first element.

Group2:

Given an array temps of doubles, containing temperature data, and an int variable n that contains the number of elements in temps, compute the average temperature. Store the average in a variable called avgTemp. Besides temps, n, and avgTemp, you may use only two other variables -- an int variable k and a double variable total, which have been declared.

Given an array arr of type int, along with two int variables i and j, write code that swaps the values of arr[i] and arr[j]. Declare any additional variables as necessary.

Reversing the elements of an array involves swapping the corresponding elements of the array: the first with the last, the second with the next to the last, and so on, all the way to the middle of the array. Given an array a, an int variable n containing the number of elements in a, and two other int variables, k and temp, write a loop that reverses the elements of the array. Do not use any other variables besides a, n, k, and temp.

Given: an int variable k, an int array currentMembers that has been declared and initialized, an int variable nMembers that contains the number of elements in the array, an int variable memberID that has been initialized, and an int variable isAMember, write code that assigns 1 to isAMember if the value of memberID can be found in currentMembers, and that assigns 0 to isAMember otherwise. Use only k, currentMembers, nMembers, and isAMember.

You are given an int variable k, an int array zipcodeList that has been declared and initialized, an int variable nZips that contains the number of elements in zipcodeList, and an int variable duplicates. Write some code that assigns 1 to duplicates if there are two adjacent elements in the array that have the same value, and that assigns 0 to duplicates otherwise. Use only k, zipcodeList, nZips, and duplicates.

Similar to the above but slightly different: You are given two int variables j and k, an int array zipcodeList that has been declared and initialized, an int variable nZips that contains the number of elements in zipcodeList, and an int variable duplicates. Write some code that assigns 1 to duplicates if any two elements in the array have the same value, and that assigns 0 to duplicates otherwise. Use only j, k, zipcodeList, nZips, and duplicates.

printArray is a function that has two parameters. The first parameter is an array of ints and the second is an int, the number of elements in the array. The function prints the contents of the array parameter; it does not return a value. How would you activate this function on an array arr already declared and filled with values, and n an integer representing the size of arr.

Write a statement that declares a prototype for a function printArray, which has two parameters. The first parameter is an array of ints and the second is an int, the number of elements in the array. The function does not return a value.

Write the definition of a function printArray, which has two parameters. The first parameter is an array of ints and the second is an int, the number of elements in the array. The function does not return a value. The function prints out each element of the array, on a line by itself, in REVERSE order of the elements appear in the array, and does not print anything else.

Write the definition of a function, isReverse, whose first two parameters are arrays of integers of equal size, and whose third parameter is an integer indicating the size of each array. The function returns true if and only if one array is the reverse of the other. ("Reverse" here means same elements but in reverse order.)

Write the definition of a function reverse, whose first parameter is an array of integers and whose second parameter is the number of elements in the array. The function reverses the elements of the array. The function does not return a value.

Given an int variable k, an int array incompletes that has been declared and initialized, an int variable nIncompletes that contains the number of elements in the array, an int variable studentID that has been initialized, and an int variable numberOfIncompletes, write code that counts the number of times the value of studentID appears in incompletes and assigns this value to numberOfIncompletes. You may use only k, incompletes, nIncompletes, studentID, and numberOfIncompletes.

Since there are only 14 questions in Group1, dulicate answers are expected. Group 2 questions offer the ability to write unique code. Answers to Group 2 must be unique.

clanguage

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!