CSC110 Chapter 11

¡Supera tus tareas y exámenes ahora con Quizwiz!

Which of the following statements about C++ arrays is true? A. Array components cannot be of floating-point types. B. The index type of a one-dimensional array can be any data type. C. An array component can be treated as a simple variable of its component type. D. a and b above E. a, b, and c above

An array component can be treated as a simple variable of its component type.

True or False? An automatic array (one that is local and not declared as static) is not reinitialized each time control reaches its destination.

False

True or False? Given the declaration int beta[20]; the statement beta = beta + 1; adds 1 to all 20 elements of the array.

False

True or False? In C++, an array can be passed as an argument either by value or by reference.

False

True or False? In C++, the component type of a one-dimensional array cannot be float, double, or long double.

False

True or False? The function heading void SomeFunc( float x[] ) causes a compile-time error because the size of the array is missing.

False

True or False? When a two-dimensional array is passed as an argument, the number of rows in the parameter must be identical to the number of rows in the argument.

False

True or False? Given the declaration int beta[20]; the expression beta[3] accesses the third component of the array.

False (start at 0)

True or False? A one-dimensional array is an example of a structured data type.

True

True or False? A static array (one that is either global or declared as static within a block) is initialized once only, when control reaches its destination.

True

True or False? An individual array component can be passed as an argument to a function.

True

True or False? C++ does not check for out-of-bounds array indexes while a program is running.

True

True or False? Given the declaration int beta[20]; the statement cout << beta; cannot be used to output all 20 elements of the array.

True

True or False? If the word const precedes the declaration of an array in a function heading, the function is prevented from modifying the array.

True

True or False? In C++, the index type of a one-dimensional array can be any integral or enumeration type.

True

True or False? In the computer's memory, C++ stores two-dimensional arrays in row order

True

True or False? It is permissible to use dot-dot notation such as // alpha[i. . . j] have been printed to specify a range of array elements even though dot dot notation is not valid C++ syntax.

True

True or False? The components of an array are all of the same data type.

True

True or False? The size of an array is established at compile time rather than at execution time.

True

True or False? The statement frequency[CLOUDY]++; is an example of the use of an array index with semantic content.

True

Copy of Which of the following statements about passing C++ arrays as arguments is false? A. At run time, the base address of the argument is passed to the function. B. When declaring a one-dimensional array in a function's parameter list, you must include its size within square brackets. C. It is impossible to pass an array by value. D. When declaring an array in a function's parameter list, you do not attach an ampersand (&) to the name of the component type.

When declaring a one-dimensional array in a function's parameter list, you must include its size within square brackets.

Which of the following statements about passing C++ arrays as arguments is false? A. At run time, the base address of the argument is passed to the function. B. When declaring an array in a function's parameter list, you do not attach an ampersand (&) to the name of the component type. C. It is impossible to pass an array by value. D. When declaring a one-dimensional array in a function's parameter list, you must include its size within square brackets.

When declaring a one-dimensional array in a function's parameter list, you must include its size within square brackets.

A(n) ____________________ is a structured collection of components, all of the same data type, that are accessed by relative position within the collection

array

Choose the most appropriate data structure with which to represent the following: a list of birth records at a hospital. A. array of records B. array C. record D. hierarchical record

array of records

The following code fragment invokes a function named InitToZero: int alpha[10][20]; InitToZero(alpha); Which of the following is a valid function heading for InitToZero? A. void InitToZero( int beta[][] ) B. void InitToZero( int beta[10][20] ) C. void InitToZero( int beta[10][] ) D. void InitToZero( int beta[][20] ) E. b and d above

b and d above

The ____________________ of an array is the memory address of the first element of the array.

base address

Which of the following cannot be used to input values into a 3-element int array named alpha? A. cin >> alpha[0]; cin >> alpha[1]; cin >> alpha[2]; B. cin >> alpha[0] >> alpha[1] >> alpha[2]; C. cin >> alpha; D. for (i = 0; i < 3; i++) cin >> alpha[i];

cin >> alpha;

If a program contains the declarations enum GarmentType {SOCKS, SLACKS, SHIRT, HAT, SWEATER}; enum StatusType {CLEAN, DIRTY, NEEDS_REPAIR}; int EddiesClothes[5][3]; // To be indexed by values of type GarmentType and StatusType then ____________________ (row or column) processing would be needed to total the number of Eddie's garments that need repair.

column

Array components often are referred to as array ____________________.

elements

True or False? An automatic array (one that is local and not declared as static) is not reinitialized each time control reaches its destination

false

True or False? If a program contains the declaration int salePrice[100][100]; then the statement cout << salePrice[3]; outputs all the values in row 3 of the array.

false

True or False? When you declare an N-dimensional array in a function's parameter list, you can omit the sizes of all but the last dimension

false

Choose the most appropriate data structure with which to represent the following: one entry in a neighborhood telephone directory consisting of a person's name, work and home numbers, and work and home addresses. A. array B. record C. array of records D. hierarchical record

hierarchical record

An individual component of a one-dimensional array is accessed by using a(n) ____________________ in square brackets to specify the component's position within the array.

integer

A(n) ____________________ array index is an index value that, in C++, is either less than zero or greater than the array size minus one.

out-of-bounds

____________________ processing refers to working with only that portion of an array that contains meaningful data values.

partial-array

If a program contains the declarations enum Genders {MALE, FEMALE}; enum Instruments {TRUMPET, CLARINET, DRUM, VIOLIN, GUITAR}; int bandArray[2][5]; // To be indexed by values of type Genders and Instruments then ____________________ (row or column) processing would be needed to total the number of females who are in the school band.

row

An array index is said to have ____________________ if it has meaning beyond simple position.

semantic content

A weather office uses a program with the declarations enum Cities { SAN_DIEGO, CHICAGO, BOSTON}; bool sunny[3][31]; The first dimension of the array is indexed by a value of type Cities, and the second is indexed by a day of the month. Which of the following could be used to record the fact that it was sunny in Boston on the twentieth day of the month? A. sunny[BOSTON][true] = 19; B. sunny[19][true] = BOSTON; C. sunny[BOSTON][19] = true; D. sunny[true][BOSTON] = 19; E. sunny[19][BOSTON] = true;

sunny[BOSTON][19] = true;

Given the declaration char table[7][9]; which of the following stores the character 'B' into the fifth row and second column of the array? A. table[4][1] = 'B'; B. table[5][2] = 'B'; C. table[5] = 'B'; D. table[1][4] = 'B'; E. table[2][5] = 'B';

table[4][1] = 'B';

True or False? A two-dimensional array can be viewed as a one-dimensional array of one-dimensional arrays.

true

True or False? As with a one-dimensional array, each index expression of a two-dimensional array must result in an integer value

true

True or False? C++ allows the elements of an array to be records (structs).

true

True or False? If a program has the declarations enum WeatherType { SUNNY, CLOUDY, FOGGY, WINDY}; int frequency[4]; then the statement cout << frequency[CLOUDY]; is syntactically valid.

true

True or False? In the computer's memory, C++ stores two-dimensional arrays in row orde

true

True or False? The array declared as float age[4][5][6][9]; has four dimensions.

true

True or False? The array declared as float angle[10][25]; has 10 rows and 25 columns.

true

True or False? The array declared as int bowlingScore[6][12]; contains 72 int components.

true

True or False? The statement int scaleFactor[2][4] = { {5, 2, 8, -2}, {6, 0, 1, 7} }; is a valid statement for declaring and initializing the scaleFactor array.

true

Given the declarations float x[300]; float y[75][4]; float z[79]; which of the following statements is true? A. x has more components than y. B. y has more components than x. C. y and z have the same number of components. D. x and y have the same number of components. E. a and c above

x and y have the same number of components.


Conjuntos de estudio relacionados

Français 1 Leçon 11 Ça fait combien?

View Set

Airframe Landing Gear Systems (A9)

View Set

PSYC 3221 - Prejudice, Discrimination, & Stereotyping

View Set