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

1. (TCO 1) Assume you have the following declaration: char nameList[100]; Which

ID: 3541148 • Letter: 1

Question

1. (TCO 1) Assume you have the following declaration:
    
    char nameList[100];
    
    Which of the following ranges is valid for the index of the array nameList? (Points : 4)                                           0 through 99
                                        0 through 100
                                        1 through 100
                                        1 through 101
                                            
                         

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

                     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}
                         

Explanation / Answer

(TCO 1) Assume you have the following declaration:

char nameList[100];

Which of the following ranges is valid for the index of the array nameList? (Points : 4)
0 through 99

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;
}

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}

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[0] >> alpha[1] >> alpha[2];

5. (TCO 1) Consider the following statement:

double alpha[10][5];

The number of components of alpha is ____. (Points : 4)

50

6. (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 1 2
    2 3 4
    4 5 6
    6 7 8

7. (TCO 1) Given the following two-dimensional array, which statement correctly sets the third column and fourth row element = 25.0?

double neoMatrix[5][5]; (Points : 4)
neoMatrix[3][2] = 25.0;

8. (TCO 2) By default, all members of a class are (Points : 4)

private.

9. (TCO 2) Given the declaration:

class myClass {
public:
void print();
int y;
private:
int x;
};
myClass myObject;

which statement is legal?

(Points : 4)
myObject.y = 10;

10. (TCO 2) Given the declaration:

class myClass
{
public:
void print();
private:
int x;
};
myClass myObject;

which statement is legal?

(Points : 4)

myObject.print();

11. (TCO 4) The constructor of a derived class (Points : 4)
can specify a call to the constructor of a base class in the body of the constructor function definition.

12. (TCO 4) Suppose that bClass is a class. Which of the following statements correctly derives the class dClass from bClass? (Points : 4)
class dClass:: public bClass{ //classMembersList};

13. (TCO 5) Given a class called Employee and the following definitions and statements:

void myFunction( Employee eptr );
Employee *emp = new Employee; (Points : 4)

myFunction(*emp);