chtp5_06-TIF-Beta

# chtp5_06-TIF-Beta - 6.1Introduction 6.1 Arrays are data...

This preview shows pages 1–4. Sign up to view the full content.

6.1  Introduction 6.1. Arrays are data structures consisting of related data items of the same __________. a) sort order b) subscript c) type d) element ANS: (c) 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 ANS: (d) 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 ANS: (c) 6.2  Arrays 6.4 An array is not (a) a consecutive group of memory locations (b) subscripted by integers (c) pointer-based (d) a dynamic entity ANS: (d) 6.5 Assuming that int a has a value of 3 and that integer array b has 7 elements, what is the correct way to assign the value of the sum of 3 and the third element, to the fifth element of the array? (a) b[ a + 1 ] = b[ a ] + 3; (b) b[ a + 1 ] = b[ a - 1 ] + 3;

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
(c) b[ a ] + 1 = b[ a + 3]; (d) b[ a + 2 ] = b[ a ] + 3; ANS: (b) 6.6 Which of the following is not true? (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. ANS: (d) 6.7. An array is a group of memory locations related by the fact that they all have __________ name and __________ type. a) different, different b) same, different c) different same d) same, same ANS: (d) 6.8. The first element in every array is the __________ element. a) null b) 1 c) 0 d) empty ANS: (c) 6.9. Which statement is false? a) The brackets used to enclose the subscript of an array are not an operator 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 subscript. 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. ANS: (a) 6.3  Defining Arrays 6.10 Which statement would be used to define a 10 element integer array c ? (a) Array c = int[ 10 ]; (b) c = int[ 10 ]; (c) int Array c[ 10 ];
(d) int c[ 10 ]; ANS: (d) 6.11. Which definition tells the computer to reserve 12 elements for integer array c ? a) c[ 12 ] int; b) int c [ 11 ]; c) c[ 11 ] int; d) int c[ 12 ]; ANS: (d) 6.6.4  Examples Using Arrays 6.12 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 }; ANS: (a) 6.13 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

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

### Page1 / 11

chtp5_06-TIF-Beta - 6.1Introduction 6.1 Arrays are data...

This preview shows document pages 1 - 4. Sign up to view the full document.

View Full Document
Ask a homework question - tutors are online