1. (TCO 1) What is the value of alpha[2] after the following code executes? int
ID: 440342 • Letter: 1
Question
1. (TCO 1) What is the value of alpha[2] after the following code executes? int alpha[5] = {0}; int j; for (j = 0; j < 3; j++) alpha[j] = 2 * j + 1; (Points : 4) 1 4 5 6 2. (TCO 1) What is stored in alpha after the following code executes? int alpha[5] = {0}; int j; for (j = 0; j < 5; j++) { alpha[j] = j + 5; if ( j % 2 == 1) //see if j is an even number alpha[j - 1] = alpha[j] + 2; } (Points : 4) alpha = {5, 6, 7, 8, 9} alpha = {5, 6, 10, 8, 9} alpha = {8, 6, 7, 8, 9} alpha = {8, 6, 10, 8, 9} 3. (TCO 1) What is the output of the following C++ code? int alpha[5] = {2, 4, 6, 8, 10}; int j; for (j = 4; j >= 0; j--) cout << "alpha[" << j << "] = " << alpha[j] << endl; (Points : 4) 2 4 6 8 10 4 3 2 1 0 8 6 4 2 0 10 8 6 4 2 4. (TCO 1) Consider the following declaration: int alpha[3]; Which of the following input statements correctly inputs values into all the array elements of alpha? (Points : 4) cin >> alpha >> alpha >> alpha; cin >> alpha[0] >> alpha[1] >> alpha[2]; cin >> alpha[1] >> alpha[2] >> alpha[3]; cin >> alpha 5. (TCO 1) Given the function prototype void strange(int a, int b); And the following declaration, int alpha[10]; int beta[10]; Which of the following is a valid call to the function strange? (Points : 4) strange(alpha[0], alpha[1]); strange(alpha, beta); strange(alpha[0], beta); strange(alpha, beta[0]); 6. (TCO 1) Consider the statement: int list[10][8]; Which statement about list is true? (Points : 4) list has 10 rows and eight columns. list has eight rows and 10 columns. list has a total of 18 components. list has a total of 108 components. 7. (TCO 1) After the following statements execute, what are the contents of matrix? int matrix[4][3] = {0}; int j, k; for (j = 0; j < 4; j++) for (k = 0; k < 3; k++) matrix[j][k] = 2 * j + k; (Points : 4) 0 2 4 1 3 5 2 4 6 3 5 7 0 1 2 1 2 3 2 3 4 3 4 5 0 2 4 2 4 6 4 6 8 6 8 10 0 1 2 2 3 4 4 5 6 6 7 8 8. (TCO 1) Given the following multidimensional array declaration, how many elements exist in the array? double neoMatrix[4][5][6]; (Points : 4) 456 60 15 120 9. (TCO 2) The member variables of a class (Points : 4) must be of the same data type. must be in the same section--either public or private. can be any data type. must be initialized in the class definition. 10. (TCO 2) In a class, all function members (Points : 4) must be public and all member variables must be private. must be public and all member variables must be public also. and member variables can be either public or private. must be private and all member variables must be public.Explanation / Answer
Answer - Value of alpha[2] = 5
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.