It is legal to use a return statement without any value in a user-defined void function.
True
If a C++ function does not use parameters, a set of parentheses around the empty parameter list is not needed
False
The number of reference parameters in the function heading must be less than the number of value parameters.
False
Any parameter that receives a value and also sends a value outside the function must be declared as a reference parameter.
True
The corresponding actual parameter for a reference parameter can be any expression
False
The content of a formal parameter that is a reference parameter is an address
True
A global identifier is an identifier declared outside of every function definition.
True
Problems caused by global variables in one area of a program can be misunderstood as problems caused in another area.
True
Any function that uses global variables is independent
False
Using global variables in a program is a better style than using local variables because extra variables can be avoided.
False
All components of an array are of the same type
True
In C++, an array index starts at index 1
False
The only allowable aggregate operations on int arrays are input and output
False
Arrays can be passed as parameters to a function by value, but it is faster to pass them by reference
False
The word “const” is used before the array declaration in a function heading to prevent the function from modifying the array.
True
The base address of an array is the memory location of the first array component
True
An array is an example of a structured data type.
True
A function cannot return a value of the type array.
True
The statement: int list[25]; declares list to be an array of 26 components, since the array index starts at 0.
False
The statement: int list[] = {5, 6, 3}; declares list to be an array of 3 components.
True
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
Two arrays are parallel if they hold the same type of data
False
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];
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
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 <= 49; j++) sales[j] = 0; b. for (int j = 1; j <= 50; j++) sales[j] = 0; c. for (int j = 0; j <= 49; j++) sales[j] = 0.0; d. for (int j = 0; j <= 50; j++) sales[j] = 0.0;
for (int j = 0; j <= 49; j++) sales[j] = 0.0;
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
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
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
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};
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];
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()
There are two types of ____ parameters: value parameters and reference parameters. a. actual c. active b. formal d. passive
formal
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)
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 <<u << " " << v << endl; }
void funcAlpha(int u, double& v) { cout << u << " " << v << endl; }
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
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
??
one = 12; letter = 'B'
What is the output of the following program? #include <iostream> 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
The ____ of an identifier refers to where in the program an identifier is accessible (visible). a. area c. scope b. lifetime d. locus
scope
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
10 15