Question
1.The _________ , also known as the address operator, returnsthe memory address of a variable. a. asterisk ( * ) b. ampersand (& ) c.
1.The _________ , also known as the address operator, returnsthe memory address of a variable. a. asterisk ( * ) b. ampersand (& ) c. percent sign ( % ) d. exclamation point ( ! )
2. With pointer variables, you can __________ manipulate datastored in other variables. a. never b. seldom c. indirectly d. Allof these
Provide a three-line (or less) C++ statement which emulates youranswer for question #2
3. The statement int *ptr; has the same meaning as a. int ptr;b. *int ptr; c. int ptr*; d. int* ptr;
4. When you work with a dereferenced pointer, you are actuallyworking with: a. a variable whose memory has been deallocated b. acopy of the value pointed to by the pointer variable c. the actualvalue of the variable whose address is stored in the pointervariable d. All of these
Provide a three-line (or less) C++ statement which emulates youranswer for question #4. Start with: int x =3;
5. These can be used as pointers. a. Array names b. Numericconstants c. Punctuation marks d. All of these e. None of these
6. The contents of pointer variables may be changed withmathematical statements that perform: a. all mathematicaloperations that are legal in C++ b. multiplication and division c.addition and subtraction d. b and c
7. A pointer may be initialized with a. the address of anexisting object b. the value of an integer variable c. the value ofa floating point variable d. all of these
8. What does the following statement do? double *num2; a. Declares a double variable named num2. b. Declaresand initializes an pointer variable named num2. c. Initializes avariable named *num2. d. Declares a pointer variable namednum2.
9. Use the delete operator only on pointers that were a. neverused b. not correctly initialized c. created with the new operatord. dereferenced inappropriately
10. A function may return a pointer, but the programmer mustensure that the pointer _________. a. still points to a validobject after the function ends b. has not been assigned an addressc. was received as a parameter by the function d. has notpreviously been returned by another function
11. True/False: A pointer with the value 0(zero) is called a NULL pointer.
12. When this is placed in front of a variable name, it returnsthe address of that variable. a. asterisk ( * ) b. conditionaloperator c. ampersand ( & ) d. semicolon ( ; )
13. What will the following statement output? Int num1 = 3; cout<< &num1; a. The value stored in the variable callednum1. b. The memory address of the variable called num1. c. Thenumber 1. d. The string "&num1". e. None of these
14. A pointer variable is designed to store a. any legal C++value. b. only floating - point values. c. a memory address. d. aninteger. e. None of these
15. Look at the following statement. int *ptr; In thisstatement, what does the word int mean? a. the variable named *ptrwill store an integer value b. the variable named *ptr will storean asterisk and an integer value c. ptr is a pointer variable thatwill store the address of an integer variable d. All of these e.None of these
16. Assuming ptr is a pointer variable, what willthe following statement output? cout << *ptr; a. thevalue stored in the variable whose address is contained in ptr. b.the string "*ptr". c. the address of the variable stored in ptr. d.the address of the variable whose address is stored in ptr.
17. The ______ and _______ operators can be used to increment ordecrement a pointer variable. a. addition, subtraction b. modulus,division c. ++, -- d. All of these e. None of these
18. Which statement displays the address of the variable num1?a. cout << num1; b. cout << *num1; c. cin >>&num1; d. cout << &num1;
19. The statement cin >> *num3; a. stores the keyboardinput into the variable num3. b. stores the keyboard input into thepointer called num3. c. stores the keyboard input into the variablepointed to by num3.
Provide an example declaration for the variable num3 prior tothe execution of the statement.
20.Dynamic memory allocation occurs a. when a new variable iscreated by the compiler b. when a new variable is created atruntime c. when a pointer fails to dereference the right variabled. when a pointer is assigned an incorrect address
21. The statement int *ptr = new int; a. results in a compilererror. b. assigns an integer less than 32767 to the variable namedptr. c. assigns an address to the variable named ptr. d. creates anew pointer named int.
22. Every byte in the computer's memory is assigned a unique a.pointer b. address c. dynamic allocation d. name
23. If a variable uses more than one byte of memory, for pointerpurposes its address is: a. the address of the last byte ofstorage. b. the average of the addresses used to store thevariable. c. the address of the FIRST byte of storage. ANS: CExplain how this relates to an array of integers
Step by Step Solution
3.38 Rating (145 Votes )
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started