CSCI TEST 3

studied byStudied by 51 people
0.0(0)
get a hint
hint

It is legal to use a return statement without any value in a user-defined void function.

1 / 39

Studying Progress

0%
New cards
40
Still learning
0
Almost done
0
Mastered
0
40 Terms
1
New cards

It is legal to use a return statement without any value in a user-defined void function.

True

New cards
2
New cards

If a C++ function does not use parameters, a set of parentheses around the empty parameter list is not needed

False

New cards
3
New cards

The number of reference parameters in the function heading must be less than the number of value parameters.

False

New cards
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

New cards
5
New cards

The corresponding actual parameter for a reference parameter can be any expression

False

New cards
6
New cards

The content of a formal parameter that is a reference parameter is an address

True

New cards
7
New cards

A global identifier is an identifier declared outside of every function definition.

True

New cards
8
New cards

Problems caused by global variables in one area of a program can be misunderstood as problems caused in another area.

True

New cards
9
New cards

Any function that uses global variables is independent

False

New cards
10
New cards

Using global variables in a program is a better style than using local variables because extra variables can be avoided.

False

New cards
11
New cards

All components of an array are of the same type

True

New cards
12
New cards

In C++, an array index starts at index 1

False

New cards
13
New cards

The only allowable aggregate operations on int arrays are input and output

False

New cards
14
New cards

Arrays can be passed as parameters to a function by value, but it is faster to pass them by reference

False

New cards
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

New cards
16
New cards

The base address of an array is the memory location of the first array component

True

New cards
17
New cards

An array is an example of a structured data type.

True

New cards
18
New cards

A function cannot return a value of the type array.

True

New cards
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

New cards
20
New cards

The statement: int list[] = {5, 6, 3}; declares list to be an array of 3 components.

True

New cards
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

New cards
22
New cards

Two arrays are parallel if they hold the same type of data

False

New cards
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];

New cards
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

New cards
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 <= 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;

New cards
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

New cards
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

New cards
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

New cards
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};

New cards
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];

New cards
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()

New cards
32
New cards

There are two types of ____ parameters: value parameters and reference parameters. a. actual c. active b. formal d. passive

formal

New cards
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)

New cards
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 <<u << " " << v << endl; }

void funcAlpha(int u, double& v) { cout << u << " " << v << endl; }

New cards
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

New cards
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

??

New cards
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'

New cards
38
New cards

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

New cards
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

New cards
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

10 15

New cards

Explore top notes

note Note
studied byStudied by 2 people
Updated ... ago
5.0 Stars(1)
note Note
studied byStudied by 154 people
Updated ... ago
5.0 Stars(4)
note Note
studied byStudied by 9 people
Updated ... ago
5.0 Stars(1)
note Note
studied byStudied by 14 people
Updated ... ago
5.0 Stars(1)
note Note
studied byStudied by 31 people
Updated ... ago
5.0 Stars(1)
note Note
studied byStudied by 56 people
Updated ... ago
5.0 Stars(1)
note Note
studied byStudied by 6 people
Updated ... ago
5.0 Stars(1)
note Note
studied byStudied by 922 people
Updated ... ago
4.9 Stars(8)

Explore top flashcards

flashcards Flashcard120 terms
studied byStudied by 15 people
Updated ... ago
5.0 Stars(1)
flashcards Flashcard123 terms
studied byStudied by 1 person
Updated ... ago
5.0 Stars(1)
flashcards Flashcard179 terms
studied byStudied by 6 people
Updated ... ago
5.0 Stars(2)
flashcards Flashcard769 terms
studied byStudied by 1 person
Updated ... ago
5.0 Stars(1)
flashcards Flashcard30 terms
studied byStudied by 7 people
Updated ... ago
5.0 Stars(1)
flashcards Flashcard70 terms
studied byStudied by 5 people
Updated ... ago
5.0 Stars(1)
flashcards Flashcard89 terms
studied byStudied by 142 people
Updated ... ago
5.0 Stars(2)
flashcards Flashcard545 terms
studied byStudied by 14942 people
Updated ... ago
4.2 Stars(399)