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

Tags and Description

test

40 Terms

1

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

True

New cards
2

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

False

New cards
3

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

False

New cards
4

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

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

False

New cards
6

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

True

New cards
7

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

True

New cards
8

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

True

New cards
9

Any function that uses global variables is independent

False

New cards
10

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

False

New cards
11

All components of an array are of the same type

True

New cards
12

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

False

New cards
13

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

False

New cards
14

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

False

New cards
15

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

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

True

New cards
17

An array is an example of a structured data type.

True

New cards
18

A function cannot return a value of the type array.

True

New cards
19

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

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

True

New cards
21

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

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

False

New cards
23

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

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

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

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

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

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

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

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

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

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

formal

New cards
33

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

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

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

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

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

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

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 1696 people
Updated ... ago
4.9 Stars(7)
note Note
studied byStudied by 11 people
Updated ... ago
5.0 Stars(1)
note Note
studied byStudied by 26 people
Updated ... ago
5.0 Stars(1)
note Note
studied byStudied by 8 people
Updated ... ago
5.0 Stars(1)
note Note
studied byStudied by 22 people
Updated ... ago
5.0 Stars(2)
note Note
studied byStudied by 13 people
Updated ... ago
5.0 Stars(1)
note Note
studied byStudied by 9 people
Updated ... ago
5.0 Stars(1)
note Note
studied byStudied by 270 people
Updated ... ago
5.0 Stars(1)

Explore top flashcards

flashcards Flashcard66 terms
studied byStudied by 1 person
Updated ... ago
5.0 Stars(1)
flashcards Flashcard151 terms
studied byStudied by 23 people
Updated ... ago
5.0 Stars(1)
flashcards Flashcard95 terms
studied byStudied by 7 people
Updated ... ago
5.0 Stars(1)
flashcards Flashcard151 terms
studied byStudied by 3 people
Updated ... ago
5.0 Stars(1)
flashcards Flashcard24 terms
studied byStudied by 71 people
Updated ... ago
4.0 Stars(1)
flashcards Flashcard56 terms
studied byStudied by 9 people
Updated ... ago
5.0 Stars(2)
flashcards Flashcard103 terms
studied byStudied by 47 people
Updated ... ago
4.8 Stars(4)
flashcards Flashcard113 terms
studied byStudied by 64 people
Updated ... ago
5.0 Stars(2)