Deck 7: Arrays and Vectors

ملء الشاشة (f)
exit full mode
سؤال
Although two-dimensional arrays are a novel idea, there is no known way to pass one to a function.
استخدم زر المسافة أو
up arrow
down arrow
لقلب البطاقة.
سؤال
Unlike regular variables, __________ can hold multiple values.

A) constants
B) named constants
C) arrays
D) floats
E) None of these
سؤال
By using the same ___________ you can build relationships between data stored in two or more arrays.

A) array name
B) data types
C) subscript
D) arguments
E) None of these
سؤال
Which of the following is a valid C++ array definition?

A) int nums[0];
B) float $payments[10];
C) void numbers[5];
D) int sizes[10];
E) None of these
سؤال
An individual array element can be processed like any other type of C++ variable.
سؤال
The following statement is a valid C++ definition:
double money[25.00];
سؤال
In C++11 you cannot use a range-based for loop to modify the contents of an array unless you declare the range variable as a reference variable.
سؤال
In C++11 the range-based for loop is best used in situations where you need the element subscript for some purpose.
سؤال
The amount of memory used by an array depends on the array's data type and the number of elements in the array.
سؤال
If an array is partially initialized, the uninitialized elements will be set to zero.
سؤال
Each individual element of an array can be accessed by the array name and the element subscript.
سؤال
C++ limits the number of array dimensions to two.
سؤال
The name of an array stores the __________ of the first array element.

A) value
B) memory address
C) element number
D) data type
E) None of these
سؤال
To access an array element, use the array name and the element's ___________.

A) data type
B) subscript
C) value
D) name
E) None of these
سؤال
The individual values contained in an array are known as

A) parts
B) items
C) constants
D) elements
E) None of these
سؤال
A vector object automatically expands in size to accommodate the items stored in it.
سؤال
If you attempt to store data past an array's boundaries, it is guaranteed to cause a compiler error.
سؤال
When you pass an array as an argument to a function, the function can modify the contents of the array.
سؤال
An array initialization must be all on one line.
سؤال
Assume array1 and array2 are the names of two arrays. To assign the contents of array2 to array1, you would use the following statement:
array1 = array2;
سؤال
The __________ is automatically appended to a character array when it is initialized with a string constant.

A) array name
B) number of elements
C) value of the first element
D) null terminator
E) None of these
سؤال
Subscript numbering in C++

A) can be set at runtime
B) can begin with a value defined by the programmer
C) varies from program to program
D) begins with zero
E) None of these
سؤال
It is _________ to pass an argument to a function that contains an individual array element, such as scores[3].

A) illegal in C++11
B) legal in C++
C) not recommended by the ANSI committee
D) not good programming practice
E) None of these
سؤال
An array with no elements is

A) legal in C++
B) illegal in C++
C) automatically furnished with one element whose value is set to zero
D) automatically furnished with one element, the null terminator
E) None of these
سؤال
An array's size declarator must be a __________ with a value greater than __________.

A) number, one
B) number, zero
C) constant integer expression, zero
D) variable, -1
E) None of these
سؤال
Given the following declaration, where is the value 77 stored in the scores array?
Int scores[] = {83, 62, 77, 97, 86}

A) scores[0]
B) scores[1]
C) scores[2]
D) scores[3]
E) scores[5]
سؤال
If you leave out the size declarator in an array definition

A) you must furnish an initialization list
B) you are not required to initialize array elements
C) all array elements default to zero values
D) your array will contain no elements
E) None of these
سؤال
An array can easily be stepped through by using a

A) a for loop
B) a reference variable
C) an array prototype
D) a null value
E) None of these
سؤال
To pass an array as an argument to a function, pass the __________ of the array.

A) contents
B) size, expressed as an integer
C) name
D) value of the first element
E) None of these
سؤال
This following statement shows an example of ___________. int grades][ ] = {100, 90, 99, 80};

A) default arguments
B) an illegal array declaration
C) an illegal array initialization
D) implicit array sizing
E) None of these
سؤال
What is the last legal subscript that can be used with the following array?
Int values[5];

A) 0
B) 5
C) 6
D) 4
E) 1
سؤال
To assign the contents of one array to another, you must use

A) the assignment operator with the array names
B) the equality operator with the array names
C) a loop to assign the elements of one array to the other array
D) Any of these
E) None of these
سؤال
A(n) __________ can be used to specify the starting values of an array.

A) initialization list
B) array name
C) subscript
D) element
E) None of these
سؤال
A two-dimensional array can be viewed as

A) rows and columns
B) arguments and parameters
C) increments and decrements
D) All of these
E) None of these
سؤال
The range-based for loop in C++11 is designed to work with a built-in variable known as

A) the counter
B) the i variable
C) an iterator
D) the range variable
E) None of these
سؤال
How many elements does the following array have?
Int values[1000];

A) 1000
B) 999
C) 1001
D) cannot tell from the code
سؤال
Which of the following is a valid C++ array definition?

A) int array[0];
B) float $payments[10.23];
C) int numbers[5.6];
D) int scores[25];
E) None of these
سؤال
An array can store a group of values, but the values must be

A) the same data type
B) integers and floating-point numbers
C) integers
D) constants
E) None of these
سؤال
An array of string objects that will hold five names would be declared with which of the following statements?

A) string names[5];
B) string names(5);
C) string names 5;
D) String[5] = names;
سؤال
Arrays must be __________ at the time they are __________.

A) sized, executed
B) re-scoped, deleted
C) initialized, declared
D) compiled, typed
E) None of these
سؤال
This vector function returns true if the vector has no elements.

A) has_no_elements
B) null_size
C) empty
D) is_empty
سؤال
When writing functions that accept multi-dimensional arrays as arguments, __________ must be explicitly stated in the parameter list.

A) all dimensions
B) all but the first dimension
C) the size declarator of the first dimension
D) all element values
E) None of these
سؤال
What will the following code display?
Int numbers[4] = {99, 87};
Cout << numbers[3] << endl;

A) 87
B) 0
C) 99
D) garbage
E) This code will not compile
سؤال
What does the following statement do?
Vector v(10);

A) It creates a vector object and initializes all its elements to the value 10.
B) It creates a vector object with a starting size of 10.
C) It creates a vector object and initializes the first element with the value 10.
D) It creates a vector object that can only store values of 10 or less.
سؤال
This vector function removes an item from a vector.

A) remove_item
B) delete_item
C) erase
D) pop_back
سؤال
This vector function returns the number of elements in a vector.

A) size
B) num_elements
C) elements
D) length
سؤال
Which statement correctly defines a vector object for holding integers?

A) vector v;
B) int vector v;
C) int v;
D) vector v;
سؤال
A two-dimensional array of characters can contain

A) strings of the same length
B) strings of different lengths
C) uninitialized elements
D) All of these
E) None of these
سؤال
An element of a two-dimensional array is referred to by

A) the array name followed by the column number of the element
B) the row subscript of the element followed by the column subscript of the element
C) a comma followed by a semicolon
D) the row subscript of the element followed by the array name
E) None of these
سؤال
A two-dimensional array can have elements of __________ data type(s).

A) one
B) two
C) four
D) any number of
E) None of these
سؤال
What will the following code display?
Int numbers[] = {99, 87, 66, 55, 101};
Cout << numbers[3] << endl;

A) 55
B) 66
C) 101
D) 87
سؤال
This vector function is used to insert an item into a vector.

A) insert_item
B) add_item
C) store
D) push_back
سؤال
Which statement correctly uses C++11 to initalize a vector of ints named n with the values 10 and 20?

A) vector n(10, 20);
B) vector n = {10, 20};
C) vector n {10, 20};
D) int vector n ({10}, {20});
سؤال
What will the following code display?
Int numbers[] = {99, 87, 66, 55, 101};
For (int i = 1; i < 4; i++)
Cout << numbers[i] << " ";

A) 99 87 66 55 101
B) 87 66 55 101
C) 87 66 55
D) Nothing. This code has an error.
سؤال
What does the following statement do?
Vector v(10, 2);

A) It creates a vector object and initializes the first two elements with the values 10 and 2.
B) It creates a vector object with a starting size of 2 and initializes the first element with the value 10.
C) It creates a vector object with a starting size of 10 and initializes the first element with the value 2.
D) It creates a vector object with a starting size of 10 and initializes all the elements with the value 2.
سؤال
What does the following code do?
Const int SIZE = 5;
Double x[SIZE];
For (int i = 2; i <= SIZE; i++)
{
X[i] = 0.0;
}

A) Each element in the array is initialized to 0.0.
B) Each element in the array except the first is initialized to 0.0.
C) Each element in the array except the first and last is initialized to 0.0.
D) An error will occur when the code runs.
فتح الحزمة
قم بالتسجيل لفتح البطاقات في هذه المجموعة!
Unlock Deck
Unlock Deck
1/56
auto play flashcards
العب
simple tutorial
ملء الشاشة (f)
exit full mode
Deck 7: Arrays and Vectors
1
Although two-dimensional arrays are a novel idea, there is no known way to pass one to a function.
False
2
Unlike regular variables, __________ can hold multiple values.

A) constants
B) named constants
C) arrays
D) floats
E) None of these
C
3
By using the same ___________ you can build relationships between data stored in two or more arrays.

A) array name
B) data types
C) subscript
D) arguments
E) None of these
C
4
Which of the following is a valid C++ array definition?

A) int nums[0];
B) float $payments[10];
C) void numbers[5];
D) int sizes[10];
E) None of these
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 56 في هذه المجموعة.
فتح الحزمة
k this deck
5
An individual array element can be processed like any other type of C++ variable.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 56 في هذه المجموعة.
فتح الحزمة
k this deck
6
The following statement is a valid C++ definition:
double money[25.00];
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 56 في هذه المجموعة.
فتح الحزمة
k this deck
7
In C++11 you cannot use a range-based for loop to modify the contents of an array unless you declare the range variable as a reference variable.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 56 في هذه المجموعة.
فتح الحزمة
k this deck
8
In C++11 the range-based for loop is best used in situations where you need the element subscript for some purpose.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 56 في هذه المجموعة.
فتح الحزمة
k this deck
9
The amount of memory used by an array depends on the array's data type and the number of elements in the array.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 56 في هذه المجموعة.
فتح الحزمة
k this deck
10
If an array is partially initialized, the uninitialized elements will be set to zero.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 56 في هذه المجموعة.
فتح الحزمة
k this deck
11
Each individual element of an array can be accessed by the array name and the element subscript.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 56 في هذه المجموعة.
فتح الحزمة
k this deck
12
C++ limits the number of array dimensions to two.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 56 في هذه المجموعة.
فتح الحزمة
k this deck
13
The name of an array stores the __________ of the first array element.

A) value
B) memory address
C) element number
D) data type
E) None of these
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 56 في هذه المجموعة.
فتح الحزمة
k this deck
14
To access an array element, use the array name and the element's ___________.

A) data type
B) subscript
C) value
D) name
E) None of these
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 56 في هذه المجموعة.
فتح الحزمة
k this deck
15
The individual values contained in an array are known as

A) parts
B) items
C) constants
D) elements
E) None of these
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 56 في هذه المجموعة.
فتح الحزمة
k this deck
16
A vector object automatically expands in size to accommodate the items stored in it.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 56 في هذه المجموعة.
فتح الحزمة
k this deck
17
If you attempt to store data past an array's boundaries, it is guaranteed to cause a compiler error.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 56 في هذه المجموعة.
فتح الحزمة
k this deck
18
When you pass an array as an argument to a function, the function can modify the contents of the array.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 56 في هذه المجموعة.
فتح الحزمة
k this deck
19
An array initialization must be all on one line.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 56 في هذه المجموعة.
فتح الحزمة
k this deck
20
Assume array1 and array2 are the names of two arrays. To assign the contents of array2 to array1, you would use the following statement:
array1 = array2;
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 56 في هذه المجموعة.
فتح الحزمة
k this deck
21
The __________ is automatically appended to a character array when it is initialized with a string constant.

A) array name
B) number of elements
C) value of the first element
D) null terminator
E) None of these
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 56 في هذه المجموعة.
فتح الحزمة
k this deck
22
Subscript numbering in C++

A) can be set at runtime
B) can begin with a value defined by the programmer
C) varies from program to program
D) begins with zero
E) None of these
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 56 في هذه المجموعة.
فتح الحزمة
k this deck
23
It is _________ to pass an argument to a function that contains an individual array element, such as scores[3].

A) illegal in C++11
B) legal in C++
C) not recommended by the ANSI committee
D) not good programming practice
E) None of these
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 56 في هذه المجموعة.
فتح الحزمة
k this deck
24
An array with no elements is

A) legal in C++
B) illegal in C++
C) automatically furnished with one element whose value is set to zero
D) automatically furnished with one element, the null terminator
E) None of these
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 56 في هذه المجموعة.
فتح الحزمة
k this deck
25
An array's size declarator must be a __________ with a value greater than __________.

A) number, one
B) number, zero
C) constant integer expression, zero
D) variable, -1
E) None of these
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 56 في هذه المجموعة.
فتح الحزمة
k this deck
26
Given the following declaration, where is the value 77 stored in the scores array?
Int scores[] = {83, 62, 77, 97, 86}

A) scores[0]
B) scores[1]
C) scores[2]
D) scores[3]
E) scores[5]
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 56 في هذه المجموعة.
فتح الحزمة
k this deck
27
If you leave out the size declarator in an array definition

A) you must furnish an initialization list
B) you are not required to initialize array elements
C) all array elements default to zero values
D) your array will contain no elements
E) None of these
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 56 في هذه المجموعة.
فتح الحزمة
k this deck
28
An array can easily be stepped through by using a

A) a for loop
B) a reference variable
C) an array prototype
D) a null value
E) None of these
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 56 في هذه المجموعة.
فتح الحزمة
k this deck
29
To pass an array as an argument to a function, pass the __________ of the array.

A) contents
B) size, expressed as an integer
C) name
D) value of the first element
E) None of these
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 56 في هذه المجموعة.
فتح الحزمة
k this deck
30
This following statement shows an example of ___________. int grades][ ] = {100, 90, 99, 80};

A) default arguments
B) an illegal array declaration
C) an illegal array initialization
D) implicit array sizing
E) None of these
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 56 في هذه المجموعة.
فتح الحزمة
k this deck
31
What is the last legal subscript that can be used with the following array?
Int values[5];

A) 0
B) 5
C) 6
D) 4
E) 1
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 56 في هذه المجموعة.
فتح الحزمة
k this deck
32
To assign the contents of one array to another, you must use

A) the assignment operator with the array names
B) the equality operator with the array names
C) a loop to assign the elements of one array to the other array
D) Any of these
E) None of these
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 56 في هذه المجموعة.
فتح الحزمة
k this deck
33
A(n) __________ can be used to specify the starting values of an array.

A) initialization list
B) array name
C) subscript
D) element
E) None of these
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 56 في هذه المجموعة.
فتح الحزمة
k this deck
34
A two-dimensional array can be viewed as

A) rows and columns
B) arguments and parameters
C) increments and decrements
D) All of these
E) None of these
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 56 في هذه المجموعة.
فتح الحزمة
k this deck
35
The range-based for loop in C++11 is designed to work with a built-in variable known as

A) the counter
B) the i variable
C) an iterator
D) the range variable
E) None of these
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 56 في هذه المجموعة.
فتح الحزمة
k this deck
36
How many elements does the following array have?
Int values[1000];

A) 1000
B) 999
C) 1001
D) cannot tell from the code
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 56 في هذه المجموعة.
فتح الحزمة
k this deck
37
Which of the following is a valid C++ array definition?

A) int array[0];
B) float $payments[10.23];
C) int numbers[5.6];
D) int scores[25];
E) None of these
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 56 في هذه المجموعة.
فتح الحزمة
k this deck
38
An array can store a group of values, but the values must be

A) the same data type
B) integers and floating-point numbers
C) integers
D) constants
E) None of these
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 56 في هذه المجموعة.
فتح الحزمة
k this deck
39
An array of string objects that will hold five names would be declared with which of the following statements?

A) string names[5];
B) string names(5);
C) string names 5;
D) String[5] = names;
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 56 في هذه المجموعة.
فتح الحزمة
k this deck
40
Arrays must be __________ at the time they are __________.

A) sized, executed
B) re-scoped, deleted
C) initialized, declared
D) compiled, typed
E) None of these
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 56 في هذه المجموعة.
فتح الحزمة
k this deck
41
This vector function returns true if the vector has no elements.

A) has_no_elements
B) null_size
C) empty
D) is_empty
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 56 في هذه المجموعة.
فتح الحزمة
k this deck
42
When writing functions that accept multi-dimensional arrays as arguments, __________ must be explicitly stated in the parameter list.

A) all dimensions
B) all but the first dimension
C) the size declarator of the first dimension
D) all element values
E) None of these
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 56 في هذه المجموعة.
فتح الحزمة
k this deck
43
What will the following code display?
Int numbers[4] = {99, 87};
Cout << numbers[3] << endl;

A) 87
B) 0
C) 99
D) garbage
E) This code will not compile
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 56 في هذه المجموعة.
فتح الحزمة
k this deck
44
What does the following statement do?
Vector v(10);

A) It creates a vector object and initializes all its elements to the value 10.
B) It creates a vector object with a starting size of 10.
C) It creates a vector object and initializes the first element with the value 10.
D) It creates a vector object that can only store values of 10 or less.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 56 في هذه المجموعة.
فتح الحزمة
k this deck
45
This vector function removes an item from a vector.

A) remove_item
B) delete_item
C) erase
D) pop_back
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 56 في هذه المجموعة.
فتح الحزمة
k this deck
46
This vector function returns the number of elements in a vector.

A) size
B) num_elements
C) elements
D) length
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 56 في هذه المجموعة.
فتح الحزمة
k this deck
47
Which statement correctly defines a vector object for holding integers?

A) vector v;
B) int vector v;
C) int v;
D) vector v;
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 56 في هذه المجموعة.
فتح الحزمة
k this deck
48
A two-dimensional array of characters can contain

A) strings of the same length
B) strings of different lengths
C) uninitialized elements
D) All of these
E) None of these
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 56 في هذه المجموعة.
فتح الحزمة
k this deck
49
An element of a two-dimensional array is referred to by

A) the array name followed by the column number of the element
B) the row subscript of the element followed by the column subscript of the element
C) a comma followed by a semicolon
D) the row subscript of the element followed by the array name
E) None of these
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 56 في هذه المجموعة.
فتح الحزمة
k this deck
50
A two-dimensional array can have elements of __________ data type(s).

A) one
B) two
C) four
D) any number of
E) None of these
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 56 في هذه المجموعة.
فتح الحزمة
k this deck
51
What will the following code display?
Int numbers[] = {99, 87, 66, 55, 101};
Cout << numbers[3] << endl;

A) 55
B) 66
C) 101
D) 87
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 56 في هذه المجموعة.
فتح الحزمة
k this deck
52
This vector function is used to insert an item into a vector.

A) insert_item
B) add_item
C) store
D) push_back
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 56 في هذه المجموعة.
فتح الحزمة
k this deck
53
Which statement correctly uses C++11 to initalize a vector of ints named n with the values 10 and 20?

A) vector n(10, 20);
B) vector n = {10, 20};
C) vector n {10, 20};
D) int vector n ({10}, {20});
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 56 في هذه المجموعة.
فتح الحزمة
k this deck
54
What will the following code display?
Int numbers[] = {99, 87, 66, 55, 101};
For (int i = 1; i < 4; i++)
Cout << numbers[i] << " ";

A) 99 87 66 55 101
B) 87 66 55 101
C) 87 66 55
D) Nothing. This code has an error.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 56 في هذه المجموعة.
فتح الحزمة
k this deck
55
What does the following statement do?
Vector v(10, 2);

A) It creates a vector object and initializes the first two elements with the values 10 and 2.
B) It creates a vector object with a starting size of 2 and initializes the first element with the value 10.
C) It creates a vector object with a starting size of 10 and initializes the first element with the value 2.
D) It creates a vector object with a starting size of 10 and initializes all the elements with the value 2.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 56 في هذه المجموعة.
فتح الحزمة
k this deck
56
What does the following code do?
Const int SIZE = 5;
Double x[SIZE];
For (int i = 2; i <= SIZE; i++)
{
X[i] = 0.0;
}

A) Each element in the array is initialized to 0.0.
B) Each element in the array except the first is initialized to 0.0.
C) Each element in the array except the first and last is initialized to 0.0.
D) An error will occur when the code runs.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 56 في هذه المجموعة.
فتح الحزمة
k this deck
locked card icon
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 56 في هذه المجموعة.