CS202 Computer Science II
In this assignment, we want to test our knowledge on pointers and reference variables and use them with
functions. You implement a function to do a specific task and then call it on variables that you create in
your main function. It is a very short assignment, but it may need some thinking.
2- Program Logic
First implement the function described in section 2-1 and then write the logic described in section 2-2 in
your main function.
2-1- getIndexAddress Function
Implement a function called “getIndexAddress”. This function has three input arguments and does not
eturn anything (the return type is void). The input arguments are as follows:
- Input a
, which is an a
ay of integers
- Input idx, which is an integer
- Input p, which is a pointer
This function puts the address of index idx of a
into the pointer p. In other words, you need to
find the element at the index idx in a
and store its address into pointer p.
• You must understand and decide how the formal parameter list of your function should look
In your main function:
- Define an a
ay of integers with size 20. Call it myA
ay and initialize it with all zeros.
- Declare an integer pointer and call it ptr.
- Get an input of type integer from the user (keyboard input). The user input value will be strictly
less than 20. Store this input integer into an integer variable called i.
- Use your implemented getIndexAddress function to assign the address of the ith element of
ay to ptr pointer, where i is the input integer value that the user provided.
- Write some code to show the co
ectness of your function and program (also use proper message