ACCURATE SOLUTIONS
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. (T/F) - Answer True
How many indexed variables does the following array have? int
myArray[12]={1,2,3,6,5,4,7,1,2}; - Answer 12
In the expression
cout << score[i]<< endl;
i is called the ________. - Answer index
The computer remembers the address of which indexed
variable(s) in an array? - Answer 0
What is wrong with the following code?
float total[8], scores[10];
a.) The 10 should be replaced with a variable name, whose value
is input from the user.
,b.) Cannot declare two array variables with different size
together.
c.) Cannot declare two array variables together
d.) nothing - Answer D
What is wrong with the following code fragment?
const int SIZE=5;
float scores[SIZE];
for( int i=0; i<=SIZE; i++){
cout<<"Enter a score";
cin>>scores[i];
}
a.) Array indexes start at 1 not 0.
b.) Arrays must be integers.
c.) Array indexes must be less than the size of the array.
d.) Should be cin >> scores[0]; - Answer C
Which of the following function declarations could be used to
input data from the keyboard into the array?
a.) void input(int array[], int &numElements, int MAX_SIZE);
b.) void input(int array[], int numElements, int MAX_SIZE);
c.) void input(int &array[], int numElements, int MAX_SIZE);
,d.) int array[] input(int array[], int &numElements, int
MAX_SIZE); - Answer A
Which of the following will correctly assign all the values in one
array to the other array? (Assume both arrays are of the same
type and have SIZE elements.)
a.) array1=array2;
b.) array1[]=array2;
c.) for(i=0;i<SIZE;i++)
array1[i]=array2[i];
d.) for(i=0;i<SIZE;i++)
array1[]=array2[]; - Answer C
The following code declares a vector of characters.vector
characters<char>
(T/F) - Answer False
Vector assignment is well behaved. (T/F) - Answer True
A string variable and a c-string are the same data type. (T/F) -
Answer False
, The function used to "put two c-strings together into one" is
called ________. - Answer strcat
A character array terminated with the null character is most
correctly called______.
a.) a c-string.
b.) a character array.
c.) a string.
d.) None of these. - Answer A
What is the value of numbers.size() after the following code?
vector<float>numbers;
numbers.reserve(100); - Answer 0
When the extraction operator is used to read data into a string
a.) it skips all white spaces.
b.) it skips only new lines.
c.) it reads everything on the line.
d.) it reads as many characters that will fit into the c-string. -
Answer A