csci exam 3 Flashcards
An array is an example of a structured data type (t/f)
true
All components of an array are of the same type (t/f)
true
If array index goes out of bounds, the program always terminates in an error. (t/f)
false
Arrays can be passed as parameters to a functions by value, but it is faster to pass them by reference.
false
The word const is used before the array declaration in a function heading to prevent the function from modifying the array. (t/f)
true
The base address of an array is the memory location of the first array component. (t/f)
true
A function cannot return a value of the type array. (t/f)
true
Two arrays are parallel id they hold the same type of data. (t/f)
false
when a two-dimensional array is declared as a parameter, the C++ compiler ignores the sizes of both dimensions (t/f)
false
Which of the following statements declares alpha to be an array of 25 components of type int?
int alpha[25];
Assume you have the following declaration char nameList[100];. Which of the following ranges is valid for the index of the array nameList?
0 trough 99
Suppose that list is an array of 10 components of type int. Which of the following codes correctly outputs all the elements of list?
for (int j = 0; j < =9; j++)
cout «_space;List[j] «” “;
cout «_space;endl;
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 «_space;list[j] «_space;” “;
cout «_space;endl;
0 5 10 15 20
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 «_space;alpha[j] «_space;” “;
cout «_space;endl;
10 8 6 4 2
Suppose that gamma is an array of 50 components of type int and j is an int variable. Which of the following for loops sets the index of gamma out of bounds?
for (j = 0; j <= 50; j++)
cout «_space;gamma[j] «_space;” “;