Accounting
Anthropology
Archaeology
Art History
Banking
Biology & Life Science
Business
Business Communication
Business Development
Business Ethics
Business Law
Chemistry
Communication
Computer Science
Counseling
Criminal Law
Curriculum & Instruction
Design
Earth Science
Economic
Education
Engineering
Finance
History & Theory
Humanities
Human Resource
International Business
Investments & Securities
Journalism
Law
Management
Marketing
Medicine
Medicine & Health Science
Nursing
Philosophy
Physic
Psychology
Real Estate
Science
Social Science
Sociology
Special Education
Speech
Visual Arts
Programming Language
Q:
Which of the following can have a pointer as an operand?
(a) ++
(b) *=
(c) %
(d) /
Q:
An expression such as
sizeof(arrayName) / sizeof(double)
might typically be used to determine
a) the size of an array
b) the number of elements in an array
c) the number of elements in half an array
d) the size of an element of an array
Q:
Which statement is false?
a) Using global variables, instead of passing arguments, can increase program performance, but reduce effective software engineering.
b) Hardcoding into a function the size of an array that will be passed as an argument rather than passing the size of the array as a parameter, reduces the software reusability of that function.
c) sizeof is an operator that calculates the size of its argument in bytes at compile time.
d) When applied to the name of an array, sizeof returns the number of elements in the array.
Q:
Which of the following gives the number of elements in the array int r[]?
(a) sizeof (r)
(b) sizeof (*r)
(c) sizeof (r) / sizeof (int)
(d) sizeof (*r) / sizeof (int)
Q:
sizeof
(a) is a binary operator
(b) returns the total number of elements in an array
(c) usually returns a double
(d) returns the total number of bytes in an array
Q:
Which statement is false?
a) The notations int *array and int array[] are interchangeable.
b) Function prototypes may not be placed inside functions.
c) Good advice: To encourage software reusability, when passing an array, also pass the size of the array.
d) Global variable violate the principle of least privilege.
Q:
The least access privilege is granted by a __________ pointer to __________ data.
a) non-constant, non-constant
b) non-constant, constant
c) constant, non-constant
d) constant, constant
Q:
When a structure must be passed to a function, we can use pointers to constant data to get the performance of a call by __________ and the protection of a call by __________.
a) value, value
b) value, reference
c) reference, value
d) reference, reference
Q:
Which statement is false?
a) Arrays and structures are aggregate data types.
b) Structures in C are sometimes called records in other languages.
c) A structure is capable of storing many related data items of different data types.
d) Structures are always passed call by reference.
Q:
The highest level of data access is granted by a
a) non-constant pointer to non-constant data.
b) non-constant pointer to constant data.
c) constant pointer to non-constant data.
d) constant pointer to constant data.
Q:
Which statement is false?
a) If a value should not change in the body of a function to which it is passed, the value should be defined const to ensure that it is not accidentally modified.
b) Attempts to modify the value of a variable defined const are caught at execution time.
c) One way to pass a pointer to a function is to use a non-constant pointer to non-constant data.
d) It is dangerous to pass a non-pointer into a pointer argument.
Q:
Which of the following most closely reflects the principle of least privilege.
a) Always grant a function at least enough access to the data in its parameters to accomplish its specified task.
b) Always grant a function enough access to the data in its parameters to accomplish its specified task, but no more.
c) Always grant a function the least amount of access to the data in its parameters.
d) Never grant a function access to the data in its parameters.
Q:
. Which statement is false?
a) The const qualifier enables the programmer to inform the compiler that the value of a particular variable should not be modified.
b) The const qualifier did not exist in early versions of C; it was added to the language by the ANSI C committee.
c) Using the const qualifier typically violates the principle of least privilege
d) Adding const to C programs that do not use it presents significant opportunities for improvement in the software engineering of that code.
Q:
What method should be used to pass an array to a function that does not modify the array and only looks at it using array subscript notation?
(a) A constant pointer to constant data.
(b) A constant pointer to nonconstant data.
(c) A nonconstant pointer to constant data.
(d) A nonconstant pointer to constant data.
Q:
A function that prints a string should have a parameter that's a
(a) nonconstant pointer to nonconstant data.
(b) nonconstant pointer to constant data.
(c) constant pointer to nonconstant data.
(d) constant pointer to constant data.
Q:
A function that modifies an array by using pointer arithmetic to process every value should have a parameter that is
(a) a nonconstant pointer to nonconstant data
(b) a nonconstant pointer to constant data
(c) a constant pointer to nonconstant data
(d) a constant pointer to constant data
Q:
Which statement is false?
a) It's necessary to include names of pointer arguments in function prototypes.
b) A function receiving an address as an argument must define a pointer parameter to receive the address.
c) The compiler does not distinguish between a function that receives a pointer and a function that receives a single-subscripted array.
d) The function must "know" whether it is receiving a single-subscripted array or simply a single variable for which it is to perform simulated call by reference.
Q:
When the __________ of a variable is passed to a function, the indirection operator (*) may be used in the function to modify the __________ at that location in the caller's memory.
a) address, address
b) value, address
c) value, value
d) address, value
Q:
If array name arrayName is passed to a function, C automatically passes __________.
a) &arrayName[0]
b) arrayName[1]
c) arrayName[0]
d) *arrayName
Q:
When calling a function with arguments that should be modified, the __________ of those arguments are passed.
a) memory
b) addresses
c) values
d) complements
Q:
Which statement is false?
a) All function calls in C pass arguments call-by-value.
b) Call-by-reference enables a called function to modify variables in the calling function.
c) Call-by-value is always more efficient than call-by-reference.
d) In C, programmers use pointers and the indirection operator to simulate call-by-reference.
Q:
When a compiler encounters a function parameter for a single-subscripted array of the form int a[], it converts the parameter to
(a) int a
(b) int &a
(c) int * a
(d) int * const a
Q:
The unary * and __________ are complements of one another.
a) /
b) ^
c) &
d) |
Q:
Which statement is generally false?
a) Initializing pointers is optional.
b) Dereferencing an uninitialized pointer could lead to a fatal execution time error.
c) Deferencing an uninitialized pointer could accidentally modify important data.
d) Derefencing an uninitialized pointer causes a syntax error.
Q:
Which statement is false?
a) The unary * operator is called the indirection operator or the dereferencing operator.
b) The operand of the unary * operator must be a pointer.
c) The unary * operator returns the value of its operand.
d) Placing a * operator before a pointer dereferences the pointer.
Q:
Which statement is false?
a) The operand of the address operator must be a variable.
b) The address operator cannot be applied to constants or to expressions.
c) The address operator can be applied to variables defined with the storage class register.
d) The address operator can be applied to variables defined with the storage class static.
Q:
The statement
y = &yPtr;
a) assigns the address of the variable y to pointer variable yPtr.
b) assigns the address of the variable yPtr to pointer variable y.
c) is a compilation error.
d) is a logic error.
Q:
The __________, or address operator, is a unary operator that returns the address of its operand.
a) &
b) &&
c) *
d) **
Q:
Three of the following expressions have the same value. Which of the following's value is different from the others?
(a) *&Ptr
(b) &*Ptr
(c) *Ptr
(d) Ptr
Q:
The & operator can be applied to
(a) constants
(b) variables defined with the storage class register
(c) variables defined with the storage class static
(d) rvalues
Q:
Which statement about pointers is false?
a) A pointer with the value NULL points to nothing.
b) NULL is a symbolic constant defined in the <stdio.h> header file.
c) Initializing a pointer to 0 is equivalent to initializing a pointer to NULL, but NULL is preferred.
d) The values 0 and 1 are the only values that can be assigned directly to a pointer variable.
Q:
Which statement about pointers is false?
a) They can be defined to point to objects of any data type.
b) The indirection operator * distributes to all comma-separated variable names in a definition.
c) The letters Ptr in a pointer variable name are optional.
d) A pointer may be initialized to 0, NULL or an address.
Q:
Referencing a value through a pointer is called __________.
a) interdiction
b) indirection
c) intermediation
d) redirection
Q:
The definition
int *count;
a) is a syntax error because only pointers can be defined with * notation.
b) is a compile-time error.
c) is a logic error.
d) is a correct definition of integer pointer count.
Q:
A non-pointer variable name __________ references a value and a pointer variable name __________ references a value.
a) directly, directly
b) directly, indirectly
c) indirectly, directly
d) indirectly, indirectly
Q:
Pointers are variables that contain __________ as their values.
a) strings
b) flowlines
c) memory addresses
d) directions
Q:
Pointers may be assigned which of the following?
(a) all integer values
(b) an address
(c) NULL
(d) both (b) and (c)
Q:
Pointers cannot be used to
(a) find the address of a variable in memory.
(b) reference values directly.
(c) simulate call-by-reference.
(d) manipulate dynamic data structures.
Q:
Assuming myString is a 20-element char array, which of the following statements might result in buffer overflow?
(a) scanf("%19s", myString);
(b) scanf_s("%s", myString, 20);
(c) scanf_s("%19s", myString, 20);
(d)scanf("%s", myString);
Q:
Which of the following statements is false?
(a) C provides automatic bounds checking for arrays.
(b) C provides no automatic bounds checking for arrays, so you must provide your own.
(c) Allowing programs to read from or write to array elements outside the bounds of arrays are common security flaws.
(d)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.
Q:
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
Q:
An array containing 3 columns and 4 rows is typically referred to as a __________.
a) 12-element array
b) 3-by-4 array
c) 13-element array, because of the zero element
d) 4-by-3 array
Q:
Which statement is false about multidimensional arrays?
a) C supports multidimensional arrays.
b) A common use of multidimensional arrays is to arrange data into tables consisting of rows and columns.
c) To identify a particular table element requires two indices.
d) Every ANSI C system can support arrays with as many indices as the programmer chooses.
Q:
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.
Q:
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
Q:
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]
Q:
A sorted array of a million elements can be searched by a binary search in __________ or fewer comparisons.
a) 10
b) 20
c) 30
d) 999,999
Q:
Which of the following statements is false?
a) The linear searching method works well for small arrays.
b) The linear searching method works well for unsorted arrays.
c) The binary search algorithm eliminates from consideration one half of the elements in a sorted array after each comparison.
d) The binary search terminates only when the search key is equal to the middle element of a subarray.
Q:
Which of these is generally thought of as a high-performance technique?
a) bubble sort
b) linear search
c) binary search
d) iteration
Q:
The maximum number of comparisons needed for the binary search of a 2000 element array is
(a) 9
(b) 15
(c) 11
(d) 14
Q:
The binary search technique
(a) is better suited to small arrays
(b) is better suited to unsorted arrays
(c) can only be used on a sorted array
(d) is slower than a linear search
Q:
The __________ is the value that occurs most frequently in the data.
a) mean
b) median
c) mode
d) master
Q:
Calculating which of the following normally requires the data to be sorted first
a) mean
b) median
c) mode
d) total
Q:
The _____ is the average value of a set of data items.
a) mean
b) median
c) mode
d) matrix
Q:
In order to calculate the __________ of an array of values, the array must be sorted.
(a) median
(b) mode
(c) mean
(d) (a), (b), and (c)
Q:
A bubble sort of 1000 elements requires a maximum of __________ passes.
a) 1001
b) 1000
c) 999
d) 998
Q:
Which statement about the bubble sort is false?
a) It is easy to program.
b) It is a high-performance sort.
c) It compares only adjacent elements with one another.
d) The bubble sort compares successive pairs of elements.
Q:
Which statement about bubble sort is true?
(a) a maximum of n passes are needed to sort the array, where n is the number of elements
(b) swapping values requires two assignments
(c) performance is maximized
(d) the algorithm is very simple compared to other sorting procedures
Q:
Which statement is true?
a) Entire arrays are passed simulated call by reference and individual array elements are normally passed simulated call by reference.
b) Entire arrays are passed simulated call by reference and individual array elements are normally passed call by value.
c) Entire arrays are passed call by value and individual array elements are normally passed simulated call by reference.
d) Entire arrays are passed call by value and individual array elements are normally passed call by value.
Q:
The special conversion specifier for printing addresses is __________.
a) %a
b) %m
c) %p
d) %loc
Q:
Which statement is false?
a) C automatically passes arrays to functions using simulated call by reference.
b) When C passes an array to a function, the called function normally can modify the element values in the caller's original array.
c) The name of an array is actually the address of the first element of the array.
d) When an array is passed in a function call, the calling function knows precisely where in the called function's memory the passed array is.
Q:
To pass an array to a function, specify
a) the name of the array without any brackets.
b) the name of the array preceded by an empty pair of brackets.
c) the name of the array followed by a pair of brackets including the size of the array.
d) the name of the array followed by a pair of brackets including a number one less than the size of the array.
Q:
To prevent modification of array values in a function,
(a) the array must be defined staticin the function.
(b) the array parameter can be preceded by the constqualifier.
(c) a copy of the array must be made inside the function.
(d) the array must be passed call-by-reference.
Q:
Which of the following is false about a function being passed an array?
(a) it knows the size of the array it was passed
(b) it is passed the address of the first element in the array
(c) it is able to modify the values stored in the array
(d) all of the above are true
Q:
Unless otherwise specified, entire arrays are passed __________ and individual array elements are passed __________.
(a) call-by-value, call-by-reference
(b) call-by-reference, call-by-value
(c) call-by-value, call-by-value
(d) call-by-reference, call-by-reference
Q:
Which statement is false?
a) A static local variable exists for the duration of the program.
b) A static local variable is visible only in the control structure in which it is defined.
c) A static local array is not created and destroyed each time the function is entered and exited, respectively.
d) Arrays that are defined static are automatically initialized once at compile time.
Q:
Which statement is false?
a) Function scanf reads characters into memory from the keyboard until the first input whitespace character is encountered.
b) Function scanf can write beyond the boundary of the array into which input is being placed.
c) Function printf does not care how large the array it is printing is.
d) When using scanf, you must always precede with the & operator the name of each variable into which inputs are being placed.
Q:
Q:
Q:
Which statement is false?
a) C has no built-in bounds checking to prevent the computer from referring to an array element that does not exist.
b) The programmer is responsible for implementing array bounds checking.
c) Referring to an element outside the array bounds is a syntax error.
d) Referring to an element outside the array bounds is a logic error.
Q:
Which statement is true regarding the statement
++frequency[responses[answer]];
a) This statement increases the appropriate frequency counter depending on the value of responses[answer].
b) This statement increases the appropriate answer counter depending on the value of frequency[responses].
c) This statement increases the appropriate responses counter depending on the value of frequency[answer].
d) This statement produces a syntax error because subscripts cannot be nested.
Q:
Which statement is true?
a) Assigning a value to a symbolic constant in an executable statement is a syntax error.
b) A symbolic constant is a variable.
c) Space is reserved for both symbolic constants and variables that hold values at execution time.
d) Only uppercase letters can be used for symbolic constant names.
Q:
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.
Q:
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.
Q:
Which statement is true?
a) Arrays are automatically initialized to zero.
b) To initialize all array elements to zeros, the array definition must explicitly 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.
Q:
If there are fewer initializers than elements in the array, the remaining elements are __________.
a) deleted
b) ignored
c) initialized to empty
d) initialized to zero
Q:
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.
Q:
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.
Q:
Q:
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