Given a two-dimensional array x of element type double, and two integer variables i and j, write an expression whose value is the i-th element in the j-th row.
  • x[4][3]
  • x[2][3] + x[4][0]
  • x[i][j]
  • a[33]
Given the array a, write an expression that refers to the first element of the array.
  • a[33]
  • a[29] = 5;
  • a [0]
  • a[0] = 3;
Declare a two-dimensional array of integers named arr with 3 rows and 10 columns.
  • const int SIZE = 8;string chessboard[SIZE][SIZE];
  • const int row = 3;const int column = 10;int arr[row][column];
  • double taxRates [] = {0.10, 0.15, 0.21, 0.28, 0.31};
  • for (int i = 0; i < 2; i++){ for (int k = 0; k <4; k++) { q[i][k] = 0; }}
Given a two-dimensional array x of element type int with 5 rows and 4 columns, write an expression whose value the last element in the array (the last column of the last row).
  • x[4][3]
  • x[2][3] + x[4][0]
  • a[33]
  • x[i][j]
Assume that an array of int named a has been declared with 12 elements and that the integer variable k holds a value between 0 andAssign 15 to the array element whose index is k
  • a[0] = 3;
  • a[k] = 15;
  • x = arr[ARR_SIZE-2] ;
  • a[k-1] = 22;
Declare an array named scores of twenty-five elements of type int.
  • const int SIZE = 8;string chessboard[SIZE][SIZE];
  • int scores[25];
  • double taxRates [] = {0.10, 0.15, 0.21, 0.28, 0.31};
  • int westboundHollandTunnelTraffic[10][52][7][24];
Given that an array of int named a has been declared, assign 3 to its first element
  • a[29] = 5;
  • a[0] = 3;
  • a[k] = 15;
  • a[k-1] = 22;
You are given a 6x8 (6 rows, 8 columns) array of integers, x, already initialized and three integer variables: max, i and j. Write the necessary code so that max will have the largest value in the array x.
  • int sumArray(int a[], int n){ int index; int sum = 0; for(index = 0; index < n; index++) sum += a[index]; return sum;}
  • max = x[0][0];for(int i = 0; i < 6; i++){ for (int j = 0; j < 8; j++){ if(x[i][j] > max) max = x[i][j]; }}
  • for (int i = 0; i < 2; i++){ for (int k = 0; k <4; k++) { q[i][k] = 0; }}
  • double taxRates [] = {0.10, 0.15, 0.21, 0.28, 0.31};
Given that an array of int named a has been declared with 12 elements and that the integer variable k holds a value between 2 andAssign 22 to the element just before a[k]
  • a[k-1] = 22;
  • a[k] = 15;
  • a[29] = 5;
  • a[0] = 3;
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
  • for (int k=0; k
  • for(total = 0, k = 0; k < n; k++) total += temps[k]; avgTemp = total / n;
  • for (int i = 0; i < 2; i++){ for (int k = 0; k <4; k++) { q[i][k] = 0; }}
  • printArray(inventory, n);
Assume that two parallel arrays have been declared and initialized: healthOption an array of type char that contains letter codes for different healthcare options and annualCost an array of type int. The i-th element of annualCost indicates the annual cost of the i-th element of healthOption. In addition, there is an char variable, best2.Write the code necessary to assign to best2 the health option with the lower annual cost, considering only the first two healthcare options. Thus, if the values of healthOption are 'B', 'Q', 'W', 'Z' and the values of annualCost are 8430, 9400, 7050, 6400 your code would assign 'B' to best2 because 8430 is less than 9400 and is associated with 'B' in the parallel array. (We ignore 'W' and 'Z' because we are considering only the first two options.)
  • int sumArray(int a[], int n){ int index; int sum = 0; for(index = 0; index < n; index++) sum += a[index]; return sum;}
  • x = arr[ARR_SIZE-2] ;
  • cout << monthSales[9];
  • int i;for(i = 0; i < 10; i++){ if(annualCost[0] > annualCost[1]) best2 = healthOption[1]; else best2 = healthOption[0];}
Write the definition of a function printArray , which has two parameters. The first parameter is an array of int s 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 the order the elements appear in the array, and does not print anything else.
  • bool isReverse (int one[], int two[], int size){ int match=0; for (int k=0; k
  • void printArray(int[], int);
  • void printArray(int s[], int m){ int n; for(n = 0; n< m; n++) cout << s[n] << endl;}
  • int sumArray(int a[], int n){ int index; int sum = 0; for(index = 0; index < n; index++) sum += a[index]; return sum;}
Given a two-dimensional array x of element type int, write an expression whose value is the sum of the element in the 3rd row/4th column and the element in the 5th row/1st column
  • x[4][3]
  • for (int i = 0; i < 2; i++){ for (int k = 0; k <4; k++) { q[i][k] = 0; }}
  • x[i][j]
  • x[2][3] + x[4][0]
Suppose v is an array with 100 int elements. If 100 is assigned to v[100], what happens?
  • for(total = 0, k = 0; k < n; k++) total += temps[k]; avgTemp = total / n;
  • Another variable or array will very likely be unexpectedly modified.
  • printArray(inventory, n);
  • for (int k=0; k
Declare a 8x8 two-dimensional array of strings named chessboard.
  • const int row = 3;const int column = 10;int arr[row][column];
  • const int SIZE = 8;string chessboard[SIZE][SIZE];
  • int westboundHollandTunnelTraffic[10][52][7][24];
  • int scores[25];
Again, consider the testPIN function used in Program 7-For convenience, we have reproduced the code for you below.Rewrite the function body of this function so that instead of using iterating through the elements of the parallel arrays, it returns true or false by calling countMatches the function defined in the previous exercise (10988), and checking its return value.
  • bool testPIN(int custPIN[], int databasePIN[], int size){ if (countMatches(custPIN, databasePIN, size)== size) return true; else return false;}
  • int sumArray(int a[], int n){ int index; int sum = 0; for(index = 0; index < n; index++) sum += a[index]; return sum;}
  • void printArray(int s[], int m){ int n; for(n = 0; n< m; n++) cout << s[n] << endl;}
  • bool isReverse (int one[], int two[], int size){ int match=0; for (int k=0; k
Given a two-dimensional array of integers named q, with 2 rows and 4 columns, write some code that puts a zero in every element of q. Declare any variables needed to help you.
  • x[2][3] + x[4][0]
  • x[i][j]
  • x[4][3]
  • for (int i = 0; i < 2; i++){ for (int k = 0; k <4; k++) { q[i][k] = 0; }}
Declare an array of integers, westboundHollandTunnelTraffic that can store the number of vehicles going westbound through the Holland Tunnel on a particular hour (numbered 0 through 23) on a particular day (numbered 0 through 6) on a particular week numbered (0 through 51) over the last ten years (numbered 0 through 9). The innermost dimension should be years, with the next being weeks, and so on.
  • int westboundHollandTunnelTraffic[10][52][7][24];
  • int denominations[] = {1, 5, 10, 25, 50, 100};
  • int scores[25];
  • double taxRates [] = {0.10, 0.15, 0.21, 0.28, 0.31};
Consider the testPIN function used in Program 7-For convenience, we have reproduced the code for you below. Modify this function as follows:change its type to int change its name to countMATCHES make it return the number of corresponding parallel elements that are equal.
  • int countMatches(int custPIN[], int databasePIN[], int size) { int matches = 0; for (int index = 0; index < size; index++) { if (custPIN[index] == databasePIN[index]) matches++; } return matches;}
  • bool isReverse (int one[], int two[], int size){ int match=0; for (int k=0; k
  • int denominations[] = {1, 5, 10, 25, 50, 100};
  • int sumArray(int a[], int n){ int index; int sum = 0; for(index = 0; index < n; index++) sum += a[index]; return sum;}
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 to x the value of the next to last element of the array ( x has already been declared ).
  • x = arr[ARR_SIZE-2] ;
  • salarySteps[4] = 160000;
  • void printArray(int[], int);
  • a[k] = 15;
Write a statement to declare and initialize an array of int 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,(The value 1 goes into the first element; the value 100 to the last.)
  • void printArray(int[], int);
  • int denominations[] = {1, 5, 10, 25, 50, 100};
  • int westboundHollandTunnelTraffic[10][52][7][24];
  • int sumArray(int a[], int n){ int index; int sum = 0; for(index = 0; index < n; index++) sum += a[index]; return sum;}
Given an array temps of double, containing temperature data, and an int variable n that contains the number of elements in temps : Compute the average temperature and store it 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.
  • printArray(inventory, n);
  • for(total = 0, k = 0; k < n; k++) total += temps[k]; avgTemp = total / n;
  • for (int i = 0; i < 2; i++){ for (int k = 0; k <4; k++) { q[i][k] = 0; }}
  • for (int k=0; k
Write a statement that declares an array of char named streetAddress that contains exactly eighty elements.
  • void printArray(int[], int);
  • salarySteps[4] = 160000;
  • int denominations[] = {1, 5, 10, 25, 50, 100};
  • char streetAddress[80];
0 h : 0 m : 1 s

Answered Not Answered Not Visited Correct : 0 Incorrect : 0