2271C Final pt.6

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

6.49 Given the following definitions, what is the value of b[1][0]? int b[2][2] = {{1}, {3, 4}}; (a) 0 (b) 1 (c) 3 (d) this isn't a valid definition

c.c

6.10 Which definition tells the computer to reserve 12 elements for in-teger array c? a) c[12] int; b) int c [11]; c) c[11] int; d) int c[12];

d

6.11 Which of the following is not a correct way to initialize an array? (a) int n[5] = {0, 7, 0, 3, 8, 2}; (b) int n[] = {0, 7, 0, 3, 8, 2}; (c) int n[5] = {7}; (d) int n[5] = {6, 6, 6};

a.

6.13 Referencing elements outside the array bounds (a) can result in changes to the value of an unrelated variable (b) is impossible because C checks to make sure it does not happen (c) is a syntax error (d) enlarges the size of the array

a.

6.8 Which statement is false? a) The brackets used to enclose the subscript of an array are not an op-erator in C. b) To refer to a particular element in an array, we specify the name of the array and the position number of the element in the array. c) The position number within an array is more formally called a sub-script. d) "Array element seven" and the "seventh element of an array" do not mean the same thing. This is a frequent source of off-by-one errors.

a.

6.14 Strings can not (a) be initialized using string literals (b) end in a character other than the null character (c) be initialized with initializer lists (d) be treated as arrays of characters

b.

6.48 A two-dimensional array element incorrectly referenced as a[x, y]is actually evaluated as (a)a[x][y] (b)a[y] (c)a[x] (d)a[0]

b.

6.53 Which initialization is not performed by the following definition? int b[2][2] = {{1}, {3, 4}}; a)b[0][0] is set to 1 b) b[0][1] is set to 1 c) b[1][0] is set to 3 d) b[1][1] is set to 4

b.

6.1 Arrays are data structures consisting of related data items of the same __________. a) sort order b) subscript c) type d) element

c.

6.12 Constant variables (a) can be assigned values in executable statements (b) do not have to be initialized when they are defined (c) can be used to specify array sizes, thereby making programs more scalable (d) can be used to specify array sizes, but this makes programs harder to understand

c.

6.15 Assume string1is a character array. Which of the following oper-ations does not produce a string? (a) string1[] = "test"; (b) string1[] = {'t', 'e', 's', 't', '\0'}; (c) string1[] = {'t', 'e', 's', 't'}; (d) string1[] = " ";

c.

6.21 Which statement is true? a) A symbolic constant is an identifier that is replaced with replacement text by the C preprocessor after the program is compiled. b) Using symbolic constants to specify array sizes makes programs run faster. c) Preprocessor directives are not C statements. d) The #define preprocessor directive must end in a semicolon.

c.

6.3 Lists, queues, stacks and trees are __________ data structures that may grow and shrink as programs execute. a) flexible b) automatic c) dynamic d) static

c.

6.7 The first element in every array is the __________ element. a) null b) 1 c) 0 d) empty

c.

6.16 Suppose a program contains the code for (i = 1; i < = 10; i++) { n[i] = 0; } Which statement about this code must be true? a) It contains an off-by-one error. b) It contains a syntax error. c) It is initializing the first 10 elements of an array. d) It is initializing successive elements of an array.

d.

6.17 What's wrong with this code? int[] = (1, 2, 3, 4, 5); a) The array size must be specified in the square brackets. b) The parentheses should be square brackets. c) The square brackets should be curly braces. d) The parentheses should be curly braces.

d.

6.18 If there are fewer initializers than elements in the array, the re-maining elements are __________. a) deleted b) ignored c) initialized to empty d) initialized to zero

d.

6.19 Which statement is true? a) Arrays are automatically initialized to zero. b) To initialize all array elements to zeros, the array definition must ex-plicitly initialize each element to zero. c) Array elements can be initialized to zero by the array definition only at compile time. d) Definitions for automatic arrays initialize the arrays at execution time.

d.

6.2 Arrays and structures are __________ entities in that they remain the same size throughout program execution. a) dynamic b) automatic c) register d) static

d.

6.20 The following array definition int n[5] = {32, 27, 64, 18, 95, 14}; a) is correct b) causes a syntax error because there are only five initializers and six array elements. c) causes a logic error because there are only five elements but there are six initializers. d) causes a syntax error because there are six initializers but only five array elements.

d.

6.26 The definition char string1[] = "first"; is equivalent to: a) character string1[] = {'f', 'i', 'r', 's', 't', '\0'}; b) char string1 = {'f', 'i', 'r', 's', 't', '\0'}; c) char string1[] = {'f', 'i', 'r', 's', 't'}; d) char string1[] = {'f', 'i', 'r', 's', 't', '\0'};

d.

6.4 An array is not ________. (a) a consecutive group of memory locations (b) indexed by integers (c) pointer-based (d) a dynamic entity

d.

6.5 Which of the following is false? (a) the first element of an array is the zeroth (b) the last element of an array is the array size - 1 (c) the position number contained within square brackets is called a subscript (d) a subscript cannot be an expression.

d.

6.50 Which of the following does not initialize all of the array elements to 0? (a) int b[2][2]; b[0][0] = b[0][1] = b[1][0] = b[1][1] = 0; (b) int b[2][2] = {0}; (c) int b[2][2]; for (int i = 0; i < 2; ++i) { for (int j = 0; j < 2; ++j) { b[i][j] = 0; } } (d) all of the above initialize all of their elements to 0.

d.

6.6 An array is a group of memory locations related by the fact that they all have __________ array name and __________ type. a) different, different b) same, different c) different same d) same, same

d.

6.9 Which statement would be used to define a 10 element integer ar-ray c? (a) Array c = int[10]; (b) c = int[10]; (c) int Array c[10]; (d) int c[10];

d.


Conjuntos de estudio relacionados

Genetic Disorders of the Endocrine System + Q(Tegay)

View Set

Chap 29: The Normal Newborn: Needs and Care

View Set

Quiz: Providing Range-of-Motion Exercises

View Set

Codeplus II HS 2 taak 2 + 3 DEFINITIE

View Set

Chapter 1, 2, & 3: Whole Numbers, Fractions, & Decimals

View Set

Chemistry - Q4 - Rate of Dissolution

View Set

Nutrition Carbohydrates and diabetes

View Set