Deck 8: Arrays

ملء الشاشة (f)
exit full mode
سؤال
When an array is passed to a function, it is actually ________ the array that is passed.

A) the starting memory address of
B) a copy of all the values in
C) the value stored in the first element of
D) the data type and size of
E) the data type and name of
استخدم زر المسافة أو
up arrow
down arrow
لقلب البطاقة.
سؤال
When you pass an array as an argument to a function, the function can modify the contents of the array.
سؤال
The amount of memory used by an array depends solely on the number of elements the array can hold.
سؤال
Which of the following statements correctly initialize the value variable?

A) int value = 8;
B) int value{8};
C) int value(8);
D) All of the above.
E) Both A and B, but not C.
سؤال
If a C++ program contains the following array definition
int score[10];
the following statement would store 100 in the first array element:
score[1] = 100;
سؤال
A two-dimensional array can be viewed as

A) two rows of values.
B) two columns of indexes.
C) a table with rows and columns.
D) any of the above.
E) none of the above.
سؤال
Which of the following statements will correctly carry out the operation stated in the comment to its right.

A) array 2 = array1 // Copy the elements of array 1 into array 2.
B) cout << array2 // Output the elements stored in array 2.
C) array2 = 5; // Place a 5 in each element of array2.
D) None of the above.
E) A and B, but not C.
سؤال
What does the following statement do?
Typedef int oneDArray[20];

A) It creates an array of 20 integers.
B) It makes oneDArray a copy of another 20-integer array.
C) It makes oneDArray an alias for a data type that holds 20 integers.
D) It creates a one-dimensional integer array with all elements initialized to 20.
E) It does none of the above.
سؤال
An element of a two-dimensional array is referenced by the array name and two subscripts, first the element row number and then the element column number.
سؤال
Unlike regular variables, arrays can hold multiple

A) data types.
B) named constants.
C) values.
D) variables.
E) operators.
سؤال
Arrays can be passed to functions, but individual array elements cannot be.
سؤال
The following statement for(int val : myArray)
Cout << val << " ";
Is an example of a(n)

A) regular for loop.
B) range-based for loop.
C) nested for loop.
D) infinite for loop.
E) illegal statement.
سؤال
When you create a vector it is unnecessary to specify how many elements it will hold because it will expand in size as you add new values to it.
سؤال
The elements of an array can be

A) strings.
B) structures.
C) objects.
D) any of the above.
E) none of the above.
سؤال
By using the same ________ you can build relationships between data stored in two or more arrays.

A) array name
B) data
C) subscript
D) arguments
E) data type
سؤال
The statement int grades[ ] = { 100, 90, 99, 80 };
Is an example of

A) default arguments.
B) an illegal array declaration.
C) an illegal array initialization.
D) data encapsulation.
E) implicit array sizing.
سؤال
If employee is an array of objects with a public member function named setHourlyWage, the following statement correctly calls this method for employee[2].
employee.setHourlyWage[2](20.00);
سؤال
The range-based for loop may be used with arrays, but not with vectors.
سؤال
To access an array element, use the array name and the element's

A) name.
B) data type.
C) value.
D) subscript.
E) size declarator.
سؤال
To step through a one-dimensional array, accessing the elements one by one, it would be most appropriate to use ________ loop.

A) an infinite
B) a sentinel controlled loop
C) a for loop
D) a nested loop
E) no
سؤال
If employee is an array of objects with a public member function named setHoursWorked, which of the following statements correctly calls that function for the employee object in array element 5?

A) employee.setHoursWorked[5] = 40;
B) employee[5].setHoursWorked = 40;
C) employee.setHoursWorked[5](40);
D) employee[5].setHoursWorked(40);
E) setHoursWorked(employee[5], 40);
سؤال
After carrying out the following two statements, sales will have been created as a one-dimensional array that can hold 20 double values.
typedef salesArray double[20];
salesArray sales;
سؤال
The following two arrays string deptName[3] = {"Manufacturing", "Sales", "Business Office");
Double deptBudget[3] = {200000.0, 60000.0, 50000.0};
Are an example of ________ arrays.

A) two-dimensional
B) paired
C) linked
D) parallel
E) brother
سؤال
The following array definition is legal because C++ allows arrays to be implicitly sized.
int grades[ ];
سؤال
In C++ If you attempt to store more data in an array than it can hold, the compiler will issue an error.
سؤال
If the scores array is defined like this: int scores[ ]= {4, 7, 4, 8, 9};
What will the following statement display?
Cout << scores[4];

A) 4
B) 7
C) 8
D) 9
E) the first four scores
سؤال
Each individual element of an array can be accessed by the array name and an element number, called a subscript.
سؤال
An individual array element can be processed or passed to a function just like a regular C++ variable.
سؤال
An array can be returned by a function as well as passed to a function.
سؤال
Subscript numbering in C++

A) can be set at run time.
B) can begin with a programmer-defined value.
C) varies from program to program.
D) automatically begins with zero.
E) automatically begins with one.
سؤال
An array can store multiple values, but the values must be

A) all the same data type.
B) declared at the time the array is created.
C) constants.
D) numeric, not characters or strings.
E) none of the above.
سؤال
The amount of memory used by an array depends upon the array's data type and how many elements it can hold.
سؤال
The following statement is a valid C++ array definition.
double money[25.00];
سؤال
Elements of vectors can be access by using the vector name and a subscript, similarly to how array elements are accessed.
سؤال
Any of the following statements can be used to initialize the integer variable num to 7;
int num = 7;
int num(7);
int num{7};
سؤال
You can assign the contents of one array to another by using

A) the assignment operator.
B) the equality operator.
C) both array names.
D) A and C together.
E) none of the above.
سؤال
When an array is passed to a function, it is actually ________ the array that is/are passed.

A) a copy of all the values in
B) the value stored in the first element of
C) the starting memory address of
D) the data type and size of
E) none of the above
سؤال
The size of an array is the number of elements that have data stored in them.
سؤال
To add up all the values in a two-dimensional array it would be best to use

A) one for loop
B) two separate for loops
C) a nested for loop
D) no loop
E) one sentinel controlled loop
سؤال
On each iteration of the following range-based for loop for (int element : myArray)
Cout << element << endl;
The variable element holds

A) an array value.
B) an array subscript.
C) an array name.
D) an array location.
E) none of the above.
فتح الحزمة
قم بالتسجيل لفتح البطاقات في هذه المجموعة!
Unlock Deck
Unlock Deck
1/40
auto play flashcards
العب
simple tutorial
ملء الشاشة (f)
exit full mode
Deck 8: Arrays
1
When an array is passed to a function, it is actually ________ the array that is passed.

A) the starting memory address of
B) a copy of all the values in
C) the value stored in the first element of
D) the data type and size of
E) the data type and name of
A
2
When you pass an array as an argument to a function, the function can modify the contents of the array.
True
3
The amount of memory used by an array depends solely on the number of elements the array can hold.
False
4
Which of the following statements correctly initialize the value variable?

A) int value = 8;
B) int value{8};
C) int value(8);
D) All of the above.
E) Both A and B, but not C.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 40 في هذه المجموعة.
فتح الحزمة
k this deck
5
If a C++ program contains the following array definition
int score[10];
the following statement would store 100 in the first array element:
score[1] = 100;
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 40 في هذه المجموعة.
فتح الحزمة
k this deck
6
A two-dimensional array can be viewed as

A) two rows of values.
B) two columns of indexes.
C) a table with rows and columns.
D) any of the above.
E) none of the above.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 40 في هذه المجموعة.
فتح الحزمة
k this deck
7
Which of the following statements will correctly carry out the operation stated in the comment to its right.

A) array 2 = array1 // Copy the elements of array 1 into array 2.
B) cout << array2 // Output the elements stored in array 2.
C) array2 = 5; // Place a 5 in each element of array2.
D) None of the above.
E) A and B, but not C.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 40 في هذه المجموعة.
فتح الحزمة
k this deck
8
What does the following statement do?
Typedef int oneDArray[20];

A) It creates an array of 20 integers.
B) It makes oneDArray a copy of another 20-integer array.
C) It makes oneDArray an alias for a data type that holds 20 integers.
D) It creates a one-dimensional integer array with all elements initialized to 20.
E) It does none of the above.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 40 في هذه المجموعة.
فتح الحزمة
k this deck
9
An element of a two-dimensional array is referenced by the array name and two subscripts, first the element row number and then the element column number.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 40 في هذه المجموعة.
فتح الحزمة
k this deck
10
Unlike regular variables, arrays can hold multiple

A) data types.
B) named constants.
C) values.
D) variables.
E) operators.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 40 في هذه المجموعة.
فتح الحزمة
k this deck
11
Arrays can be passed to functions, but individual array elements cannot be.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 40 في هذه المجموعة.
فتح الحزمة
k this deck
12
The following statement for(int val : myArray)
Cout << val << " ";
Is an example of a(n)

A) regular for loop.
B) range-based for loop.
C) nested for loop.
D) infinite for loop.
E) illegal statement.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 40 في هذه المجموعة.
فتح الحزمة
k this deck
13
When you create a vector it is unnecessary to specify how many elements it will hold because it will expand in size as you add new values to it.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 40 في هذه المجموعة.
فتح الحزمة
k this deck
14
The elements of an array can be

A) strings.
B) structures.
C) objects.
D) any of the above.
E) none of the above.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 40 في هذه المجموعة.
فتح الحزمة
k this deck
15
By using the same ________ you can build relationships between data stored in two or more arrays.

A) array name
B) data
C) subscript
D) arguments
E) data type
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 40 في هذه المجموعة.
فتح الحزمة
k this deck
16
The statement int grades[ ] = { 100, 90, 99, 80 };
Is an example of

A) default arguments.
B) an illegal array declaration.
C) an illegal array initialization.
D) data encapsulation.
E) implicit array sizing.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 40 في هذه المجموعة.
فتح الحزمة
k this deck
17
If employee is an array of objects with a public member function named setHourlyWage, the following statement correctly calls this method for employee[2].
employee.setHourlyWage[2](20.00);
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 40 في هذه المجموعة.
فتح الحزمة
k this deck
18
The range-based for loop may be used with arrays, but not with vectors.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 40 في هذه المجموعة.
فتح الحزمة
k this deck
19
To access an array element, use the array name and the element's

A) name.
B) data type.
C) value.
D) subscript.
E) size declarator.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 40 في هذه المجموعة.
فتح الحزمة
k this deck
20
To step through a one-dimensional array, accessing the elements one by one, it would be most appropriate to use ________ loop.

A) an infinite
B) a sentinel controlled loop
C) a for loop
D) a nested loop
E) no
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 40 في هذه المجموعة.
فتح الحزمة
k this deck
21
If employee is an array of objects with a public member function named setHoursWorked, which of the following statements correctly calls that function for the employee object in array element 5?

A) employee.setHoursWorked[5] = 40;
B) employee[5].setHoursWorked = 40;
C) employee.setHoursWorked[5](40);
D) employee[5].setHoursWorked(40);
E) setHoursWorked(employee[5], 40);
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 40 في هذه المجموعة.
فتح الحزمة
k this deck
22
After carrying out the following two statements, sales will have been created as a one-dimensional array that can hold 20 double values.
typedef salesArray double[20];
salesArray sales;
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 40 في هذه المجموعة.
فتح الحزمة
k this deck
23
The following two arrays string deptName[3] = {"Manufacturing", "Sales", "Business Office");
Double deptBudget[3] = {200000.0, 60000.0, 50000.0};
Are an example of ________ arrays.

A) two-dimensional
B) paired
C) linked
D) parallel
E) brother
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 40 في هذه المجموعة.
فتح الحزمة
k this deck
24
The following array definition is legal because C++ allows arrays to be implicitly sized.
int grades[ ];
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 40 في هذه المجموعة.
فتح الحزمة
k this deck
25
In C++ If you attempt to store more data in an array than it can hold, the compiler will issue an error.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 40 في هذه المجموعة.
فتح الحزمة
k this deck
26
If the scores array is defined like this: int scores[ ]= {4, 7, 4, 8, 9};
What will the following statement display?
Cout << scores[4];

A) 4
B) 7
C) 8
D) 9
E) the first four scores
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 40 في هذه المجموعة.
فتح الحزمة
k this deck
27
Each individual element of an array can be accessed by the array name and an element number, called a subscript.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 40 في هذه المجموعة.
فتح الحزمة
k this deck
28
An individual array element can be processed or passed to a function just like a regular C++ variable.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 40 في هذه المجموعة.
فتح الحزمة
k this deck
29
An array can be returned by a function as well as passed to a function.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 40 في هذه المجموعة.
فتح الحزمة
k this deck
30
Subscript numbering in C++

A) can be set at run time.
B) can begin with a programmer-defined value.
C) varies from program to program.
D) automatically begins with zero.
E) automatically begins with one.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 40 في هذه المجموعة.
فتح الحزمة
k this deck
31
An array can store multiple values, but the values must be

A) all the same data type.
B) declared at the time the array is created.
C) constants.
D) numeric, not characters or strings.
E) none of the above.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 40 في هذه المجموعة.
فتح الحزمة
k this deck
32
The amount of memory used by an array depends upon the array's data type and how many elements it can hold.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 40 في هذه المجموعة.
فتح الحزمة
k this deck
33
The following statement is a valid C++ array definition.
double money[25.00];
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 40 في هذه المجموعة.
فتح الحزمة
k this deck
34
Elements of vectors can be access by using the vector name and a subscript, similarly to how array elements are accessed.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 40 في هذه المجموعة.
فتح الحزمة
k this deck
35
Any of the following statements can be used to initialize the integer variable num to 7;
int num = 7;
int num(7);
int num{7};
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 40 في هذه المجموعة.
فتح الحزمة
k this deck
36
You can assign the contents of one array to another by using

A) the assignment operator.
B) the equality operator.
C) both array names.
D) A and C together.
E) none of the above.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 40 في هذه المجموعة.
فتح الحزمة
k this deck
37
When an array is passed to a function, it is actually ________ the array that is/are passed.

A) a copy of all the values in
B) the value stored in the first element of
C) the starting memory address of
D) the data type and size of
E) none of the above
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 40 في هذه المجموعة.
فتح الحزمة
k this deck
38
The size of an array is the number of elements that have data stored in them.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 40 في هذه المجموعة.
فتح الحزمة
k this deck
39
To add up all the values in a two-dimensional array it would be best to use

A) one for loop
B) two separate for loops
C) a nested for loop
D) no loop
E) one sentinel controlled loop
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 40 في هذه المجموعة.
فتح الحزمة
k this deck
40
On each iteration of the following range-based for loop for (int element : myArray)
Cout << element << endl;
The variable element holds

A) an array value.
B) an array subscript.
C) an array name.
D) an array location.
E) none of the above.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 40 في هذه المجموعة.
فتح الحزمة
k this deck
locked card icon
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 40 في هذه المجموعة.