|
Question 1.1. (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 2.2. (TCO 1) After the following statements execute, what are the contents of the 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 3.3. (TCO 1) After the following statements execute, what are the contents of the 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
|
|
Question 4.4. (TCO 1) Which of the following correctly declares and initializes alpha to be an array of 4 rows and 3 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}};
|
|
Question 5.5. (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}
|
|
Question 6.6. (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 7.7. (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 8.8. (TCO 2) If a member of a class is ____, you cannot access it outside the class. (Points : 4)
|
public
automatic
private
static
|
|
Question 9.9. (TCO 2) Consider the following class definition.
class rectangleType
{
public:
void setLengthWidth(double x, double y);
//Postcondition: length = x; width = y;
void print() const;
//Output length and width;
double area();
//Calculate and return the area of the rectangle;
double perimeter();
//Calculate and return the parameter;
rectangleType();
//Postcondition: length = 0; width = 0;
rectangleType(double x, double y);
//Postcondition: length = x; width = y;
private:
double length;
double width;
};
And consider this declaration.
rectangleType bigRect;
Which of the following statements is correct? (Points : 4)
|
rectangleType.print();
rectangleType::print();
bigRect.print();
bigRect::print();
|
|
Question 10.10. (TCO 2) In C++, the ____ is an operator called the member access operator. (Points : 4)
|
.
,
::
#
|
|