Instruction
Question 2: Assume that myList is a previously declared an initialized array. Assume that the variable length holds the total number of elements in the array. Complete the line to display each element of the array in the body of the loop. Fill in the blank only; do not type the entire line, just provide what is missing. for (int i = 0; i a >> b; if( b == 0 ) { cout instead of << Question 20: To use an array of strings in your code, which of the following do you need? Group of answer choices #include #include #include prefix string with std:: or include this statement: using namespace std; Question 21: What does this function do? int mystery(double employees[], double id, int size) { for (int i = 0; i < size; i++) { if (id == employees[i]) { return i; } } return -1; } Group of answer choices This is a function that performs a search. If the id is found in the employees array, its index location is returned, otherwise -1 is returned. This is a function that returns all index numbers in the employees array, one at a time. Once the entire array has been processed, -1 is returned. This is a function that swaps the value in the id variable with the value in the employees array at index i. If the swap cannot be performed, -1 is returned. This is a function that sorts the employees array Question 22: Which of the following function calls would successfully call this function? (Select all that apply) void swapShellsFirstInArray(int basket[]) { int temp = basket[0]; basket[0] = basket[1]; basket[1] = temp; } Group of answer choices int collection[5] = {3, 2, 1, 4, 6}; swapShellsFirstInArray(collection); int collection[10] = {3, 2, 1, 4, 6}; swapShellsFirstInArray(collection); int collection[] = {3, 2}; swapShellsFirstInArray(collection); int collection[]; swapShellsFirstInArray(collection); int collection[3] = {3, 2, 1}; swapShellsFirstInArray(collection); Question 23: The numbers to the left represent the line numbers, but are not part of the code. What is wrong with this function? 1 void swapShells(int &n1, int &n2) 2 { 3 int temp = n1; 4 n1 = n2; 5 n2 = temp; 6 return temp; 7 } Group of answer choices The return type is wrong in the function header The n1 and n2 variables are not defined. The parameter list causes a syntax error Question 24: Consider the following switch block which should only handle values 1, 2, 3 and 4. Any other value should trigger the error message. Provide the missing line: int input = 1; cin << input; switch ( input ) { case 1: cout << "Case 1\n"; break; case 2: cout << "Case 2\n"; break; case 3: cout << "Case 3\n"; break; case 4: cout << "Case 4\n"; break; _______________ //provide this missing line cout << "Error: bad input\n"; break; } Question 25: Which of the following switch block is error free? (select all that apply) Group of answer choices char a = '1'; char b = '1'; char c = '2'; switch ( a ) { case '1': // Code break; case '2': // Code break; default: // Code break; } int a = 1; int b = 1; int c = 2; switch ( a ) { case 1: // Code break; case 2: // Code break; default: // Code break; } int a = 1; int b = 1; int c = 2; switch ( a ) { case b: // Code break; case c: // Code break; default: // Code break; }