Lecture 23- Pointers

Pataasin ang iyong marka sa homework at exams ngayon gamit ang Quizwiz!

2. 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

13. Assuming that t is an array and tPtr is a pointer to that array, what expression refers to the address of element 3? (a) *(tPtr + 3) (b) tPtr[3] (c) &t[3] (d) *(t + 3)

(c) &t[3]

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

(c) memory addresses

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

a) &

11. 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

8. 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 syntax error.

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

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

b) indirection

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

c) &

12. If bPtr is assigned b (the name of an array), then array element b[3] can alternatively be referenced with the pointer expression __________. a) bPtr + 3 b) b[bPtr + 3] c) *b [bPtr + 3] d) *(bPtr + 3)

d) *(bPtr + 3)

6. 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 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.

3. 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.

5. 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.

9. 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.

d) Derefencing an uninitialized pointer causes a syntax error.


Kaugnay na mga set ng pag-aaral

g/r exam 3 - stages of pregnancy & fetal development

View Set

NASM - Chapter 5; End of Chapter Quiz

View Set

Chapter 18- Assessing mouth throat nose and sinuses

View Set

Finance 301 Module 2 Questions (OWL QUIZ 3+4 + Definitions)

View Set

AP Euro Final Exam Ch 20-25 McKay

View Set

18 -19. Overview of the Literary Prophets: Five Main Themes

View Set