|
|
|
|
|
|
|
1. Declare an array named quiz that contains 12 components indexed by the integers 0 through 11. The component type is Boolean. (Assume that type Boolean has already been defined.) (pp. 594-596) |
|
|
|
|
|
|
|
|
2. If an array is to hold the number of correct answers given by students to each question on a 20-question true/false quiz, what data type should be used for the components of the array? (pp. 594-596) |
|
|
|
|
|
|
|
|
3. Given the declarations |
|
|
|
 |
|
|
|
|
const int MAX_LENGTH = 30;
char firstName[MAX_LENGTH]; |
|
|
|
 |
|
|
|
|
write an assignment statement that stores 'A' into the first component of array firstName. (pp. 596-599) |
|
|
|
|
|
|
|
|
4. Given the declarations in Question 3, write an output statement that prints the value of the fourteenth component of array firstName. (pp. 596-599) |
|
|
|
|
|
|
|
|
5. Given the declarations in Question 3, write a For statement that fills array firstName with blanks, (pp. 599-601) |
|
|
|
|
|
|
|
|
6. Declare a five-element int array named oddNums, And initialize it (in its declaration) to contain the first five odd integers, starting with 1. (pp. 601-602) |
|
|
|
|
|
|
|
|
7. Give the function heading for a void function named SomeFunc, where |
|
|
|
 |
|
|
|
|
a. SomeFunc has a single parameter: a float array x that is an Inout parameter. |
|
|
|
 |
|
|
|
|
b. SomeFunc has a single parameter: a float array x that is an In parameter. (pp. 608-610) |
|
|
|
|
|
|
|
|
8. Given the declarations in Question 3 and the following program fragment, which reads characters into array firstName until a blank is encountered, write a For statement that prints out the portion of the array that is filled with input data. (pp. 610-613) |
|
|
|
 |
|
|
|
|
length = 0;
do
{
cin.get(letter);
if (letter != ' ')
{
firstName[length] = letter;
length++;
}
} while (letter != ' '); |
|
|
|
|
|
|
|
|
9. Declare two parallel arrays indexed by the integers 0 through 99. One of the arrays will contain student ID numbers (type long); the other will consist of values of the enumeration type defined by |
|
|
|
 |
|
|
|
|
enum GenderType {FEMALE, MALE}; |
|
|
|
 |
|
|
|
|
(pp.610-613) |
|
|
|
|
|
|
|
|
10. Define an enumeration type for the musical notes A through G (excluding sharps and fiats). Then declare an array in which the index values represent musical |
|
|
|
|
|