All instructions/questions are referring to one code, please anwser them all Use this source code as a
Question:
All instructions/questions are referring to one code, please anwser them all
Use this source code as a guide:
Code the following:
a) Allocate the array in main at the location indicated by the comment. Answer this question in your mind: why can you not allocate the array inside of the function fillArray()? Try playing with the location where you allocate it (main vs. inside fillArray() ) to convince yourself of how pass-by-pointer works.
b) Complete the definition of the function fillArray(), in which the function places values into the array based on the arguments passed: the pointer to the array, a count of the number of elements, and a factor f. The function should set Array[i] equal to i * f, for all valid elements of the array.
2) Convert the for loop in main to use the base + offset pointer notation. This changes element access to a[i] into *(a + i) notation.
3) If you have't already (from step (1), code the for loop in the function to use a temporary pointer that you increment, instead of the array index. In this case, you can use the passed-in parameter Array as a pointer and increment it (it doesn't matter that you'll lose the pointer inside the function). Use pointer arithmetic (i.e. Array++) to get to the "next" location in the array, and dereference the Array pointer to access the elements using (*Array).
Income Tax Fundamentals 2013
ISBN: 9781285586618
31st Edition
Authors: Gerald E. Whittenburg, Martha Altus Buller, Steven L Gill