COMP220 Final Exam 2 (Perfect Tutorial)
To download this tutorial follow the link - http://homework-tutorials.com/product/comp220-final-exam-2-perfect-tutorial/
Page 1
Multiple Choice
1. (TCO 1) Which of the following about C++ arrays is true?
(i) Array components must be of type double.
(ii) The array index must be of an integral type. (Points : 4)
Only (i)
Only (ii)
Both (i) and (ii)
None of these
2. (TCO 1) What is stored in alpha after the following code executes?
int alpha[5] = {0};
int j;
for (; j < 5; j++)
{
alpha[j] = 2 * j;
if (j % 2 == 1) //see if j is an even number
alpha[j - 1] = alpha[j] + j;
}
(Points : 4)
alpha = {0, 2, 4, 6, 8}
alpha = {0, 2, 9, 6, 8}
alpha = {0, 3, 4, 7, 8}
alpha = {3, 2, 9, 6, 8}
3. (TCO 1) What is the value of alpha[3] after the following code executes?
int alpha[6] = {0};
int j;
for(; j >= 0; j-)
{
alpha[j] = j + 5;
if (j % 2 == 0)
alpha[j + 1] = alpha[j] + 3;
Page 1
Multiple Choice
1. (TCO 1) Which of the following about C++ arrays is true?
(i) Array components must be of type double.
(ii) The array index must be of an integral type. (Points : 4)
Only (i)
Only (ii)
Both (i) and (ii)
None of these
2. (TCO 1) What is stored in alpha after the following code executes?
int alpha[5] = {0};
int j;
for (; j < 5; j++)
{
alpha[j] = 2 * j;
if (j % 2 == 1) //see if j is an even number
alpha[j - 1] = alpha[j] + j;
}
(Points : 4)
alpha = {0, 2, 4, 6, 8}
alpha = {0, 2, 9, 6, 8}
alpha = {0, 3, 4, 7, 8}
alpha = {3, 2, 9, 6, 8}
3. (TCO 1) What is the value of alpha[3] after the following code executes?
int alpha[6] = {0};
int j;
for(; j >= 0; j-)
{
alpha[j] = j + 5;
if (j % 2 == 0)
alpha[j + 1] = alpha[j] + 3;