Intro to Programming - Chapter 7

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

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 sim-ulate call-by-reference.

c) Call-by-value is always more efficient than call-by-reference.

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.

b) The indirection operator * distributes to all comma-separated variable names in a definition.

When calling a function with arguments that should be modified, the __________ of those arguments are passed. a) memory b) addresses c) values d) complements

b) addresses

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-sub-scripted array or simply a single variable for which it is to perform simulated call by reference.

a) It's necessary to include names of pointer arguments in function prototypes.

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.

(b) reference values directly.

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

(c) *Ptr

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

(c) int * a

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

(c) variables defined with the storage class static

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

b) directly, indirectly

The unary * and __________ are complements of one another. a) / b) ^ c) & d) |

c) &

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.

c) The address operator can be applied to variables defined with the storage class register.

Which statement is false? a) The unary * operator is called the indirection operator or the deref-erencing 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.

c) The unary * operator returns the value of its operand.

Pointers are variables that contain __________ as their values. a) strings b) flowlines c) memory addresses d) directions

c) memory addresses

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 im-portant data. d) Derefencing an uninitialized pointer causes a syntax error.

d) Derefencing an uninitialized pointer causes a syntax error.

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.

d) The values 0 and 1 are the only values that can be assigned directly to a pointer variable.

When the __________ of a variable is passed to a function, the indi-rection 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

d) address, value

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.

d) is a correct definition of integer pointer count.

Pointers may be assigned which of the following? (a) all integer values (b) an address (c) NULL (d) both (b) and (c)

(d) both (b) and (c)

The __________, or address operator, is a unary operator that returns the address of its operand. a) & b) && c) * d) **

a) &

If array name arrayName is passed to a function, C automatically passes __________. a) &arrayName[0] b) arrayName[1] c) arrayName[0] d) *arrayName

a) &arrayName[0]

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.

b) assigns the address of the variable yPtr to pointer variable y.

Referencing a value through a pointer is called __________. a) interdiction b) indirection c) intermediation d) redirection

b) indirection


Conjuntos de estudio relacionados

Chapter #10: Recordings - From Bach to Rock and Rap

View Set

Abnormal Psychology Oltmanns Exam 3 - Chapter 9, 10, 11

View Set

Organizational Behavior: Chapter 1-4

View Set

Chapter 13.5 Dynamic Programming

View Set