1. (TCO 1) What is the output of the following C++ code? int list[5] = {0, 5, 10
ID: 3664102 • Letter: 1
Question
1. (TCO 1) What is the output of the following C++ code?
int list[5] = {0, 5, 10, 15, 20};
int j;
for (j = 0; j < 5; j++)
cout << list[j];
(Points : 4)
0 1 2 3 4
0 5 10 15
0 5 10 15 20
5 10 15 20
Question 2.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}
Question 3.3. (TCO 1) What is the output of the following C++ code?
int alpha[5] = {2, 4, 6, 8, 10};
int j;
for (j = 4; j >= 0; j--)
cout << "alpha[" << j << "] = " << alpha[j] << endl;
(Points : 4)
2 4 6 8 10
4 3 2 1 0
8 6 4 2 0
10 8 6 4 2
Question 4.4. (TCO 1) Which of the following about arrays as function parameters is true?
(i) Arrays are passed by reference only.
(ii) When we declare an array as a formal parameter we do not attach & after the data type of the array component. (Points : 4)
Only (i)
Only (ii)
Both (i) and (ii)
None of these
Question 5.5. (TCO 1) Consider the following statement:
double alpha[10][5];
The number of components of alpha is _____. (Points : 4)
15
50
100
150
Question 6.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}};
Question 7.7. (TCO 1) Given the following declaration:
int j;
int sum;
double sale[10][7];
which of the following correctly finds the sum of the elements of the fifth row of sale? (Points : 4)
sum = 0;
for(j = 0; j < 7; j++)
sum = sum + sale[5][j];
sum = 0;
for(j = 0; j < 7; j++)
sum = sum + sale[4][j];
sum = 0;
for(j = 0; j < 7; j++)
sum = sum + sale[j][4];
sum = 0;
for(j = 0; j < 7; j++)
sum = sum + sale[j][5];
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) In C++, class is a reserved word that defines (Points : 4)
a data type.
an object type.
a variable.
an enumeration.
Question 10.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.
1. (TCO 1) What is the output of the following C++ code?
int list[5] = {0, 5, 10, 15, 20};
int j;
for (j = 0; j < 5; j++)
cout << list[j];
(Points : 4)
0 1 2 3 4
0 5 10 15
0 5 10 15 20
5 10 15 20
Explanation / Answer
Answers:
Question 1 : Will print the Answer like 0 5 10 15 20 from 0 to 5 Option C
Question 2 : Alpha is having the Answer like 8 6 10 8 9 from 0 to 5 Option D
Question 3 : Will print the Answer like 10 8 6 4 2 from 5 to 0 Option D
Question 4 : Option A i.e Only 1 because Arrays are passed by Reference only.
Question 5 : Total 50 components are present in alpha array
Question 6: Option 4
Question 7: Option B is correct
for(j = 0; j < 7; j++)
sum = sum + sale[4][j];
Question 8 : 120 elements are present in neoMatrix Option D
Question 9 : class will define an object Option B
Question 10: member variables can be either public or private.
Option C
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.