Test 03 with Answer

Test 03 with Answer - Test 3 for COP2220 True/False...

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

View Full Document Right Arrow Icon
Test 3 for COP2220 True/False Indicate whether the sentence or statement is true or false. ____ 1. ____ 2. A variables address is the last byte occupied by the variable. ____ 3. Because addresses are pointer constants, pointers cannot be initialized. ____ 4. While pointers can be passed to a function, they cannot be returned. ____ 5. As long as the type are the same, one pointer can point to another pointer. ____ 6. The name of an array is a pointer constant to the first element. ____ 7. Because an array name is a pointer constant, it is by definition an lvalue. ____ 8. When we add an n to a pointer value, we get the sum of the address and the value n . ____ 9. The result of adding an integer to a pointer can be stored in a pointer variable. ____ 10. When an array is statically allocated, the number of bytes cannot be changed during the program execution. ____ 11. Block memory allocation allocates a block of memory from the heap and initializes contents to null values. ____ 12. In general, a string is a series of characters treated as a unit. ____ 13. C strings are delimited by a null character. ____ 14. A string constant is a sequence of characters enclosed in single quotes. ____ 15. The string length function returns the number of characters in a string including the delimiter (null character). Multiple Choice Identify the letter of the choice that best completes the statement or answers the question. ____ 16. Which of the following statements about pointer constants is true? a. The value in a pointer constant can change from run to run. b. The type of a pointer constant is address. c. The asterisk operator (*) extracts the address for a variable. d. Pointer constants cannot be saved. e. The address in a pointer constant is the last byte when it refers to a multibyte variable such as an integer. ____ 17. Which of the following statements about pointer variables is false? a. To access a variable through a pointer, we use the indirection operator (*). b. Only one pointer can be pointing to a variable at a time. c. The indirection and address operators are the inverse of each other.
Background image of page 1

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

View Full DocumentRight Arrow Icon
d. To declare and define a pointer variable, we suffix its type with an asterisk. e. To change a pointer variable so that it is pointing to nothing, we assign it the value NULL. ____ 18. Which of the following declares a pointer variable to an integer? a. int& p; c. int* p; b. int% p; d. int^ p;
Background image of page 2
____ 19. Which of the following statements about pointer initialization is true? a. Pointer constants can only point to constants. b. Pointer constants can only be initialized to null pointers. c. Pointer constants are automatically set to null by the compiler. d.
Background image of page 3

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

View Full DocumentRight Arrow Icon
Image of page 4
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 03/01/2012 for the course COP 2220 taught by Professor Colinarchibald during the Spring '11 term at Valencia.

Page1 / 10

Test 03 with Answer - Test 3 for COP2220 True/False...

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

View Full Document Right Arrow Icon
Ask a homework question - tutors are online