Homework 3: Questions for Pointers ================================== Due date: Wednesday March 29, 11:59pm 1. Assume the variable declarations: int Foo = 0; int *ptr = &Foo; Which of the following statements will change the value of Foo to 1? 1) ptr++; 2) Foo++; 3) (*Foo)++; 4) (*ptr)++ For question 2 through 6, consider the following implementation of a function to find the maximum value in an array of integers. The for loop is required to be implemented using pointers to access elements rather than direct array indexing. int maxEntry(const int* const Data, int Sz) { //Line 1 if ( Data == NULL || Sz <= 0 ) // 2a return INT_MIN; // 2b int Count; // 3 // Set hiSoFar to point to the first array element: const int *hiSoFar = ________; // 4 // Set Current to point to the second array element: const int *Current = ________; // 5 for (Count=1 ; Count < Sz; ________ ) { // 6 if(________) // 7 hiSoFar = Current; // 8 } return ( ________ ); // 9 } 2. How should the blank in Line 4 be filled? 1) Data 2) *Data 3) &Data 4) &Data[0] 5) Data[0] 3. How should the blank in Line 5 be filled? 1) hiSoFar 2) hiSoFar++ 3) Data++ 4) &Data[1] 4. How should the blank in Line 6 be filled? 1) Count++ 2) Current++ 3) Count++, Current++ 4) It should be left blank. 5) None of these [revisit this, once you filled in the next question.] 5. How should the blank in Line 7 be filled? 1) Current > hiSoFar 2) &Current > &hiSoFar 3) *Current < *hiSoFar 4) None of these 6. How should the blank in Line 9 be filled? 1) *hiSoFar 2) &hiSoFar 3) hiSoFar 4) It should be left blank 5) None of these 7. Consider implementing a function to dynamically allocate an array of integers and set all its elements to zero: void ZeroIt( __________ A, const int Size) { A = new int[Size]; for (int Idx = 0; Idx < Size; Idx++) { A[Idx] = 0; } } Which of the following choices for the blank preceding the formal parameter A is the best? 1) int* 2) int*& 3) const int* 4) int* const 5) const int* const 6) All of the above