Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

1. (TCO 1) Which of the following statements declares alpha to be an array of 25

ID: 3549564 • Letter: 1

Question

1. (TCO 1) Which of the following statements declares alpha to be an array of 25 components of the type int? (Points : 4)                                        int alpha[25];
                                        int array alpha[25];
                                        int alpha[2][5];
                                        int array alpha[25][25];
              
Question 2.   2. (TCO 1) What is the value of alpha[4] after the following code executes?

int alpha[5] = {0};
int j;
alpha[0] = 2;
for (j = 1; j < 5; j++)
      alpha[j] = alpha[j - 1] + 3; (Points : 4)                                       5
                                        8
                                        11
                                        14
              
Question 3.   3. (TCO 1) What is the value of alpha[3] after the following code executes?
  
int alpha[6] = {0};
int j;
for(j = 4; j >= 0; j--)
{
         alpha[j] = j + 5;
         if (j % 2 == 0)
                alpha[j + 1] = alpha[j] + 3;
} (Points : 4)                                       5
                                        8
                                        9
                                        10
              
Question 4.   4. (TCO 1) Suppose that the array alpha is to be declared as a formal parameter in a function heading. Which of the following about alpha is true?
(i) You must specify the size of alpha in square brackets.
(ii) You cannot pass alpha by value. (Points : 4)                                       Only (i)
                                        Only (ii)
                                        Both (i) and (ii)
                                        Neither of these
              
Question 5.   5. (TCO 1) Given the function prototype:
void mystery(int list[], int size);
And the declaration:
int alpha[50];
Which of the following is a valid call to the function mystery? (Points : 4)                                       mystery(alpha[50]);
                                        mystery(alpha[], 50);
                                        mystery(alpha, 50);
                                        mystery(alpha{50});
              
Question 6.   6. (TCO 1) After the following statements execute, what are the contents of matrix?

int matrix[3][2] = {0};
int j, k;
for (j = 0; j < 3; j++)
        for (k = 0; k < 2; k++)
               matrix[j][k] = j + k; (Points : 4)                                       0 0
1 1
2 2
                                        0 1
2 3
4 5
                                        0 1
1 2
2 3
                                        1 1
2 2
3 3
              
Question 7.   7. (TCO 1) Consider the following statements.
int beta[10][5] = {0};
int j, k;
Which of the following statements correctly outputs the elements of beta one row per line?

(i)
for (j = 0; j  < 10; j++)
{
        for (k = 0; k < 5; k++)
               cout << beta[j][k];    
        cout << endl;
}
(ii)
for (j = 0; j  < 10; j++)
        for (k = 0; k < 5; k++)
      {
               cout << beta[j][k];    
               cout << endl;
      } (Points : 4)                                       Only (i)
                                        Only (ii)
                                        Both (i) and (ii)
                                        None of these
              
Question 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
              
Question 9.   9. (TCO 2) A public member function of a class can access (Points : 4)                                       only other public members of the class.
                                        public and nonpublic members of a class.
                                        only private members of a class.
                                        neither public nor private class members.
              
Question 10.   10. (TCO 2) A class and its members can be described graphically by using (Points : 4)                                       Unified Modeling Language (UML) notation.
                                        a flowchart.
                                        Unified Abstract Language (UAL) notation.
                                        Unified Encapsulation Language (UEL) notation. Question 2.   2. (TCO 1) What is the value of alpha[4] after the following code executes?

int alpha[5] = {0};
int j;
alpha[0] = 2;
for (j = 1; j < 5; j++)
      alpha[j] = alpha[j - 1] + 3; (Points : 4)                                       5
                                        8
                                        11
                                        14

Explanation / Answer

. (TCO 1) Which of the following statements declares alpha to be an array of 25 components of the type int? (Points : 4)

int alpha[25];

Question 2. 2. (TCO 1) What is the value of alpha[4] after the following code executes?

int alpha[5] = {0};
int j;
alpha[0] = 2;
for (j = 1; j < 5; j++)
alpha[j] = alpha[j - 1] + 3; (Points : 4)

alpha[1] = alpha[0]+3 = 2+3 = 5;
alpha[2] = alpha[1]+3 = 5+3 = 8;
alpha[3] = alpha[2]+3 = 8+3 = 11;
alpha[4] = alpha[3]+3 = 11+3 = 14;

14 is answer.

Question 3. 3. (TCO 1) What is the value of alpha[3] after the following code executes?

int alpha[6] = {0};
int j;
for(j = 4; j >= 0; j--)
{
alpha[j] = j + 5;
if (j % 2 == 0)
alpha[j + 1] = alpha[j] + 3;
} (Points : 4)

alpha[4] = 4+5 = 9
alpha[3] = 3+5 = 8

since 4%2 == 0
alpha[5] = alpha[4] + 3 = 9+3 = 12
alpha[3] = 3+5 = 8
alpha[2] = 2+5 = 7
since 2%2 == 0
alpha[3] = alpha[2] + 3 = 7+3 = 10

10

Question 4. 4. (TCO 1) Suppose that the array alpha is to be declared as a formal parameter in a function heading.
Which of the following about alpha is true?
(i) You must specify the size of alpha in square brackets.
(ii) You cannot pass alpha by value. (Points : 4)

Neither of these

Question 5. 5. (TCO 1) Given the function prototype:
void mystery(int list[], int size);
And the declaration:
int alpha[50];
Which of the following is a valid call to the function mystery? (Points : 4)

mystery(alpha, 50);

Question 6. 6. (TCO 1) After the following statements execute, what are the contents of matrix?

int matrix[3][2] = {0};
int j, k;
for (j = 0; j < 3; j++)
for (k = 0; k < 2; k++)
matrix[j][k] = j + k; (Points : 4)

0 1
1 2
2 3


Question 7. 7. (TCO 1) Consider the following statements.
int beta[10][5] = {0};
int j, k;
Which of the following statements correctly outputs the elements of beta one row per line?

(i)
for (j = 0; j < 10; j++)
{
for (k = 0; k < 5; k++)
cout << beta[j][k];
cout << endl;
}
(ii)
for (j = 0; j < 10; j++)
for (k = 0; k < 5; k++)
{
cout << beta[j][k];
cout << endl;
} (Points : 4)

Only (i)


Question 8. 8. (TCO 1) Given the following multidimensional array declaration, how many elements exist in the array?
double neoMatrix[4][5][6]; (Points : 4)

120 = 4*5*6

Question 9. 9. (TCO 2) A public member function of a class can access (Points : 4)

public and nonpublic members of a class.

Question 10. 10. (TCO 2) A class and its members can be described graphically by using (Points : 4)

Unified Modeling Language (UML) notation.