2. (TCO 1) What is stored in alpha after the following code executes? int alpha[
ID: 3633759 • Letter: 2
Question
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 stored in alpha after the following code executes?
int alpha[5] = {0};
int j;
for (j = 0; j < 5; j++)
{
alpha[j] = j + 1;
if (j > 2)
alpha[j - 1] = alpha[j] + 2;
} (Points : 4)
alpha = {1, 2, 6, 7, 5}
alpha = {1, 2, 3, 4, 5}
alpha = {4, 5, 6, 7, 9}
None of these
4. (TCO 1) Consider the following declaration:
int alpha[5] = {3, 5, 7, 9, 11};
Which of the following is equivalent to this statement? (Points : 4)
int alpha[] = {3, 5, 7, 9, 11};
int alpha[] = {3 5 7 9 11};
int alpha[5] = [3, 5, 7, 9, 11];
int alpha[] = (3, 5, 7, 9, 11);
5. (TCO 1) Suppose alpha is an array of 50 components. Which of the following about alpha is true?
(i) The base address of alpha is the address of alpha[0].
(ii) The base address of alpha is the address of alpha[1]. (Points : 4)
Only (i)
Only (ii)
Both (i) and (ii)
None of these
6. (TCO 1) Which of the following correctly declares and initializes alpha to be an array of four rows and three columns with the component type int? (Points : 4)
int alpha[4][3] = {{0,1,2} {1,2,3} {2,3,4} {3,4,5}};
int alpha[4][3] = {0,1,2; 1,2,3; 2,3,4; 3,4,5};
int alpha[4][3] = {0,1,2: 1,2,3: 2,3,4: 3,4,5};
int alpha[4][3] = {{0,1,2}, {1,2,3}, {2,3,4}, {3,4,5}};
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) Considering the following statement:
double alpha[10][5];
what is the last row and column element of the array? (Points : 4)
alpha[10][5]
alpha[9][4]
alpha[10][4]
alpha[9][5]
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
Dear,
2. Values stored in alpha alpha = {8, 6, 10, 8, 9}
3. Values stored in alpha alpha = {1, 2, 6, 7, 5}
4.Equivalent statement int alpha[] = {3, 5, 7, 9, 11};
5. (i) The base address of alpha is the address of alpha[0].
only(i)
6. int alpha[4][3] = {{0,1,2}, {1,2,3}, {2,3,4}, {3,4,5}};
7. values stored in matrix
0 1 2
2 3 4
4 5 6
6 7 8
8) alpha[9][4]
9) can be any data type.
10) must be public and all member variables must be private.
Hope this will help you..
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.