Chapter 6

Ace your homework & exams now with Quizwiz!

Which of the following statements is false? 1. C provides automatic bounds checking for arrays. 2. C provides no automatic bounds checking for arrays, so you must provide your own. 3. Allowing programs to read from or write to array elements outside the bounds of arrays are common security flaws. 4. Writing to an out-of-bounds element (known as a buffer overflow) can corrupt a program's data in memory, crash a program and allow attackers to exploit the system and execute their own code.

1. C provides automatic bounds checking for arrays.

Which statement is false? 1. The brackets used to enclose the subscript of an array are not an operator in C. 2. 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. 3. The position number within an array is more formally called a subscript. 4. "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.

1. The brackets used to enclose the subscript of an array are not an operator in C.

Referencing elements outside the array bounds 1. can result in changes to the value of an unrelated variable 2. is impossible because C checks to make sure it does not happen 3. is a syntax error 4. enlarges the size of the array

1. can result in changes to the value of an unrelated variable

Which of the following is false about a function being passed an array? 1. it knows the size of the array it was passed 2. it is passed the address of the first element in the array 3. it is able to modify the values stored in the array 4. all of the above are true

1. it knows the size of the array it was passed

Which statement is false? 1. A static local variable exists for the duration of the program. 2. A static local variable is visible only in the control structure in which it is defined. 3. A static local array is not created and destroyed each time the function is entered and exited, respectively. 4. Arrays that are defined static are automatically initialized once at compile time.

2. A static local variable is visible only in the control structure in which it is defined.

Which statement is true? 1. Entire arrays are passed simulated call by reference and individual array elements are normally passed simulated call by reference. 2. Entire arrays are passed simulated call by reference and individual array elements are normally passed call by value. 3. Entire arrays are passed call by value and individual array elements are normally passed simulated call by reference. 4. Entire arrays are passed call by value and individual array elements are normally passed call by value.

2. Entire arrays are passed simulated call by reference and individual array elements are normally passed call by value.

Which statement about the bubble sort is false? 1. It is easy to program. 2. It is a high-performance sort. 3. It compares only adjacent elements with one another. 4. The bubble sort compares successive pairs of elements.

2. It is a high-performance sort.

Unless otherwise specified, entire arrays are passed __________ and individual array elements are passed __________. 1. call-by-value, call-by-reference 2. call-by-reference, call-by-value 3. call-by-value, call-by-value 4. call-by-reference, call-by-reference

2. call-by-reference, call-by-value

To prevent modification of array values in a function, 1. the array must be defined static in the function. 2. the array parameter can be preceded by the const qualifier. 3. a copy of the array must be made inside the function. 4. the array must be passed call-by-reference.

2. the array parameter can be preceded by the const qualifier.

The maximum number of comparisons needed for the binary search of a 2000 element array is 1. 9 2. 15 3. 11 4. 14

3. 11

Constant variables 1. can be assigned values in executable statements 2. do not have to be initialized when they are defined 3. can be used to specify array sizes, thereby making programs more scalable 4. can be used to specify array sizes, but this makes programs harder to understand

3. can be used to specify array sizes, thereby making programs more scalable

An array containing 3 columns and 4 rows is typically referred to as a __________.

4 by 3 array

Which statement is false? 1. Function scanf reads characters into memory from the keyboard until the first input whitespace character is encountered. 2. Function scanf can write beyond the boundary of the array into which input is being placed. 3. Function printf does not care how large the array it is printing is. 4. When using scanf, you must always precede with the & operator the name of each variable into which inputs are being placed

4. When using scanf, you must always precede with the & operator the name of each variable into which inputs are being placed

An array is not ________. 1. a consecutive group of memory locations 2. indexed by integers 3. pointer-based 4. a dynamic entity

4. a dynamic entity.

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

4. it is initializing successive elements of an array.


Related study sets

US History Chapter 10 - Version 2

View Set

Lesson 2 Estructura 2.2 Forming questions in Spanish Review

View Set

INS3003 Final Wahhabism to Militant Jihadism

View Set

Marketing Learning Objectives Unit 1

View Set

Psych Exam 1 - Ch. 3 (Psychobiology & Psychopharmacology)

View Set

Frankenstein Chapter 5-10 Vocabs

View Set

Macroeconomics: Unit 4 -Module 9:

View Set