Question
QUESTION 1 The statement typedef int oneDArray[20]; does which of the following? Note the use of typedef. -makes oneDArray an alias for a data type
QUESTION 1
The statement
typedef int oneDArray[20];
does which of the following? Note the use of "typedef".
-makes oneDArray an alias for a data type that holds 20 integers | ||
-creates a one-dimensional integer array with all elements initialized to 20 | ||
-makes oneDArray a copy of another 20-integer array | ||
-creates an array of 20 integers | ||
-None of the above |
QUESTION 2
True/False: 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.
-True
-False
QUESTION 3
If defining 100 different storage locations of the type Item, the best method is to:
-use variables: Item item1, item2, item3, ... , item99, item100; | ||
-None of these work, because arrays can only contain native types like: int, float, double, etc. | ||
-use a two dimensional array: Item itemArray[100][2]; | ||
-use an array: [100] of Item; | ||
-use an array: Item itemArray[100]; |
QUESTION 4
An array of 10 integers named myArray can have its contents displayed with which of the following statements?
-cout << myArray[0-9]; | ||
-cout << myArray[]; | ||
-cout << myArray; | ||
-cout << myArray[10]; | ||
-for (int i = 0; i < 10; i++) {cout << myArray[i] << " ";} |
QUESTION 5
Any two-dimensional array can be viewed as ________.
-a table with rows and columns | ||
-two columns | ||
-two rows | ||
-any of the above | ||
-None of the above |
QUESTION 6
If you leave out the size declarator in an array declaration ________.
-the array cannot be created | ||
-the array size defaults to 100 elements | ||
-the value of each array element is set to a default value of 0 | ||
-you must furnish an initialization list | ||
-the array will contain no elements |
QUESTION 7
-True/False: The amount of memory used by an array depends solely on the number of elements the array can hold, and is not dependent upon the data type of each element.
- True
- False
QUESTION 8
True/False: If a C++ program contains the following array definition
int score[10];
the following statement would store 100 in the very first array element
score[1] = 100;
- True
-False
QUESTION 9
True/False: To assign the entire contents of one array to another, you can use the assignment operator.
-True
-False
QUESTION 10
If a programmer defines: int myArray[10]; and then sets: myArray[12] = 123; what happens?
-The compiler issues an error, something like: "myArray is not big enough to hold 123" | ||
-There is no compiler error. At run-time, the computer attempts to store the value of 123 off the end of myArray. This could result in crashing the program. | ||
-There is no compiler error. At run-time, the computer skips the assignment statement to be sure that 123 is not written in an invalid location. | ||
-The array myArray is expanded in size to hold a new 12th element. | ||
-The person who designed C++ runs up and says: "Don't expect me to prevent you from shooting yourself in the foot." |
QUESTION 11
To step through a one-dimensional array, accessing the elements one by one, it would be most appropriate to use ________ loop.
-a nested loop | ||
-no | ||
-a for loop | ||
-an infinite | ||
-a sentinel controlled loop |
QUESTION 12
True/False: The following statement initializes all five elements of the number array to 1.
int number[5] = {1};
-True
-False
QUESTION 13
True/False: A one-dimensional array can only store elements of a single data type, but a two-dimensional array can hold data of two different data types.
-True
- False
QUESTION 14
True/False: When you pass an array as an argument to a function, the function can modify the contents of the array.
- True
-False
QUESTION 15
True/False: The following statement adds a new element to a the department vector at index 25.
department.push_back(25);
-True
-False
QUESTION 16
True/False: Assuming 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);
- True
-False
QUESTION 17
When an array is passed to a function by reference, it is actually ________ the array that is/are passed.
-the starting memory address of | ||
-the data type and name of | ||
-a copy of all the values in | ||
-the data type and size of | ||
-the value stored in the first element of |
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started