Send a link to your students to track their progress
40 Terms
1
New cards
It is legal to use a return statement without any value in a user-defined void function.
True
2
New cards
If a C++ function does not use parameters, a set of parentheses around the empty parameter list is not needed
False
3
New cards
The number of reference parameters in the function heading must be less than the number of value parameters.
False
4
New cards
Any parameter that receives a value and also sends a value outside the function must be declared as a reference parameter.
True
5
New cards
The corresponding actual parameter for a reference parameter can be any expression
False
6
New cards
The content of a formal parameter that is a reference parameter is an address
True
7
New cards
A global identifier is an identifier declared outside of every function definition.
True
8
New cards
Problems caused by global variables in one area of a program can be misunderstood as problems caused in another area.
True
9
New cards
Any function that uses global variables is independent
False
10
New cards
Using global variables in a program is a better style than using local variables because extra variables can be avoided.
False
11
New cards
All components of an array are of the same type
True
12
New cards
In C++, an array index starts at index 1
False
13
New cards
The only allowable aggregate operations on int arrays are input and output
False
14
New cards
Arrays can be passed as parameters to a function by value, but it is faster to pass them by reference
False
15
New cards
The word โconstโ is used before the array declaration in a function heading to prevent the function from modifying the array.
True
16
New cards
The base address of an array is the memory location of the first array component
True
17
New cards
An array is an example of a structured data type.
True
18
New cards
A function cannot return a value of the type array.
True
19
New cards
The statement: int list[25]; declares list to be an array of 26 components, since the array index starts at 0.
False
20
New cards
The statement: int list[] = {5, 6, 3}; declares list to be an array of 3 components.
True
21
New cards
Consider the following array declarations: int myList[5] = {10, 12, 14, 16, 18}; int yourList[5]; If you needed to copy the elements of โmyListโ into the corresponding elements of โyourListโ you could use the statement: yourList = myList;
False
22
New cards
Two arrays are parallel if they hold the same type of data
False
23
New cards
Which of the following statements declares alpha to be an array of 25 components of the type int? a. int alpha[25]; b. int array alpha[25]; c. int alpha[2][5]; d. int array alpha[25][25];
int alpha[25];
24
New cards
Assume you have the following declaration: char nameList[100];. Which of the following ranges is valid for the index of the array โnameListโ? a. 0 through 99 b. 0 through 100 c. 1 through 100 d. 1 through 101
0 through 99
25
New cards
Suppose that โsalesโ is an array of 50 components of type double. Which of the following correctly initializes the array โsalesโ? a. for (int 1 = 1; j
for (int j = 0; j
26
New cards
What is the value of โalpha[2]โ after the following code executes? int alpha[5]; int j; for (j = 0; j < 5; j++) alpha[j] = 2 * j + 1; a. 1 b. 4 c. 5 d. 6
5
27
New cards
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] << " "; cout << endl; a. 0 1 2 3 4 b. 0 5 10 15 c. 0 5 10 15 20 d. 5 10 15 20
0 5 10 15 20
28
New cards
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] << " "; cout << endl; a. 2 4 6 8 10 b. 4 3 2 1 0 c. 8 6 4 2 0 d. 10 8 6 4 2
10 8 6 4 2
29
New cards
Consider the following declaration: int alpha[5] = {3, 5, 7, 9, 11};. Which of the following is equivalent to this statement? a. int alpha[] = {3, 5, 7, 9, 11}; b. int alpha[] = {3 5 7 9 11}; c. int alpha[5] = [3, 5, 7, 9, 11]; d. int alpha[] = (3, 5, 7, 9, 11);
int alpha[] = {3, 5, 7, 9, 11};
30
New cards
Consider the following declaration: int alpha[3];. Which of the following input statements correctly inputs values into alpha? a. cin >> alpha >> alpha >> alpha; c. cin >> alpha[1] >> alpha[2] >> alpha[3]; b. cin >> alpha[0] >> alpha[1] >> alpha[2]; d. cin >> alpha
cin >> alpha[0] >> alpha[1] >> alpha[2];
31
New cards
Suppose that โprintHeadingโ is a function without any parameters. Which of the following is a valid function heading? a. void printHeading(); b. void printHeading() c. void printHeading(noParameters); d. void printHeading(void)
void printHeading()
32
New cards
There are two types of ____ parameters: value parameters and reference parameters. a. actual c. active b. formal d. passive
formal
33
New cards
A void function accomplish has three parameters: a parameter โuโ of type int, a parameter โvโ of type double, and a parameter โletterโ of type char. The parameters โuโ and โletterโ need to pass their values out of the function and the parameter โvโ is to only receive the value from the calling environment. Which of the following is a correct function heading? a. void accomplish(int& u, double v, char& letter) b. void accomplish(int u, double& v, char letter) c. void accomplish(int& u, double v, char& letter); d. void accomplish(int u, double& v, char letter);
void accomplish (int& u, double v, char& letter)
34
New cards
Which of the following is a legal C++ function definition? a. void funcAlpha(int u, double v &) { cout << u << " " << v << endl; } b. void funcAlpha(int #, double #) { cout << u << " " << v << endl; } c. void funcAlpha(int &, double &) { cout << u << " " << v << endl; } d. void funcAlpha(int u, double& v) { cout <}
void funcAlpha(int u, double& v) { cout << u << " " << v << endl; }
35
New cards
During program execution, a(n) ____ parameter manipulates the data stored in its own memory space. a. formal value c. active b. default value d. passive
formal value
36
New cards
If a formal parameter is a reference parameter, its corresponding actual parameter during a function call must be a(n) ____. a. default value c. expression b. value d. variable
??
37
New cards
Consider the following function definition. void strange(int& u, char& ch) { int a; a = u++; u = 2 * u; a = static_cast(ch); a++; ch = static_cast(a); } What are the values of โoneโ and โletterโ after the following statements execute? int one = 5; char letter = 'A'; strange(one, letter); a. one = 5; letter = 'A' b. one = 10; letter = 'A' c. one = 10; letter = 'B' d. one = 12; letter = 'B'
one = 12; letter = 'B'
38
New cards
What is the output of the following program? #include using namespace std; void one(int x, int& y); void two(int& s, int t); int main() { int u = 1; int v = 2; one(u, v); cout << u << " " << v << endl; two(u, v); cout << u << " " << v << endl; return 0; } void one(int x, int& y) { int a; a = x; x = y; y = a; } void two(int& s, int t) { int b; b = s โ t; s = t + b + 2; t = 4 * b; } a. 1 1 3 1 b. 1 2 1 3 c. 1 2 2 3 d. 2 2 2 3
11, 32 or 11, 31
39
New cards
The ____ of an identifier refers to where in the program an identifier is accessible (visible). a. area c. scope b. lifetime d. locus
scope
40
New cards
What is the output of the following C++ code? int alpha = 5; int beta = 10; alpha = alpha + 5; { int alpha = 20; beta = beta + 5; } cout << alpha << " " << beta << endl; a. 10 10 c. 10 15 b. 20 15 d. 15 10