midterm ch 7 arrays Flashcards
1
Q
- The indexed variables (members) of an array must be integers. t/f
A
FALSE
2
Q
- The locations of the various indexed variables in an array can be spread out all over the memory. T/F
A
FALSE
3
Q
- The following array declaration is legal: double scores[]={0.1,0.2,0.3};
A
TRUE
4
Q
- Arrays can be passed to functions. T/F
A
TRUE
5
Q
- Arrays can be returned from a function.
A
FALSE
6
Q
- If a function is expecting a pass by reference parameter, you can pass an index variable from an array of the same base type to that function.
A
TRUE
7
Q
- When you have a function that expects an array, it should also expect the size of the array or the number of indexed variables with valid data.
A
TRUE
8
Q
- The following function declaration guarantees the values in the array argument are not changed:
void function1(int array[], int numElements);
A
FALSE
9
Q
- The following function will work with any size integer array.
void function1(int array[], int numElements);
A
TRUE
10
Q
- If you use the const modifier in a function declaration, you do not include it in the function definition.
A
FALSE
11
Q
- Write the code to declare a two dimension array of integers with 10 rows and 20 columns.
A
ANSWER: int array[10][20];
12
Q
- Write the code to declare an array of 10 doubles named list;
A
ANSWER: double list[10];
13
Q
- The modifier that guarantees that an array argument will not be changed is called ______.
A
ANSWER: const
14
Q
- How many indexed variables does the following array have?
int myArray[]={1,2,3,6,5,4,7,1,2};
A
ANSWER: 9
15
Q
- How many indexed variables does the following array have?
int myArray[12]={1,2,3,6,5,4,7,1,2};
A
ANSWER: 12
16
Q
- Write the declaration for a function named funct1 that expects an array of floats, the number of elements in the array and does not return any value.
A
ANSWER: void funct1(float myArray[], int numElements);
17
Q
- If you put a value in the square brackets of a one-dimension array parameter, this value is _________ by the compiler.
A
ANSWER: ignored
18
Q
- If your index used to access the indexed variables of the array has the value of a non-existent index, this is called _________
A
ANSWER: Index out of range, Index out of bounds, or illegal.
19
Q
- The computer remembers the address of which indexed variable(s) in an array? ______
A
ANSWER: the first
20
Q
- A computer’s memory consists of numbered locations called __________.
A
ANSWER: bytes
21
Q
- In the expression
double score[10];
double is called the ___________ of the array
A
ANSWER: base type
22
Q
- In the expression
cout «_space;score[i] «_space;endl;
i is called the
A
ANSWER: index or subscript