12. The purpose of an array name is to a. assign b. declare d. locate 13. If gra
ID: 3738847 • Letter: 1
Question
12. The purpose of an array name is to a. assign b. declare d. locate 13. If grade is an array, trying to store its address using the expression &grade; results in a c. compiler error d. scaling error b. normal execution 14. Under a dynamic allocation scheme, the amount of storage to be allocated is determined and adjusted at compile time at runtime c. when a program error occurs d. interactively by the user a. b. The only address required by the delete operator is the a. pointer 15. address of the block of storage that was c. starting d. ending b. offset 16. When an array is passed to a function, its is the only item actually passed. a. value b. data type c. address d. offset 17. A pointer included as a parameter in a function header. a. b. can not be can be c. d. should not be is rarely 18. Given the following information, fill the blanks with either "an address"or "3.75" float *pointer float pay 3.75 pointer-&pay; coutExplanation / Answer
12. Ans: d. locate
When an array is declared such as int arr[10], arr is the name of the array that is containing the starting address of the array and is used to locate where in the memory the array resides.
13. Ans: b. normal execution
If we want to store the address of the array in a pointer, such as int *ptr; ptr = &arr; it will work just fine as a pointer expects an address.
14. Ans: b. at runtime
The word ‘dynamic’ itself means moving or running. In dynamic memory allocation scheme, the storage space for a variable can be allocated while the program is in execution. It is done using a pointer that stores the address to the dynamic space that is needed to be allocated during runtime.
15. Ans: a. pointer.
The ‘delete’ operator frees up the space that was pointed by a pointer used during the dynamic memory allocation of a storage space.
16. Ans: c. address
The address of the array is represented by the array name itself. So, when we want to call a function in which we need to pass the array, we just pass the array name as parameter which corresponds to the array address. Like: function(arr);
17. Ans: b. can be
Yes, we can use a pointer in a function header. In cases like, passing array to the function, passing an address to the function, etc. Eg, void function(unsigned int *);
18. OUTPUT:
An address. // as just name of the pointer represents the address of the variable pointed by it. i.e., pay.
3.75. // the * is known as the dereferencing operator that gives the value stored at the address pointed by the pointer.
An address. // & operator is the referencing operator that gives the address of the variable
3.75 //simply prints the value of the float variable pay
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.