Great Deal! Get Instant $10 FREE in Account on First Order + 10% Cashback on Every Order Order Now

CS202 Computer Science II Assignment #3 1- Description 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...

1 answer below »
CS202 Computer Science II
Assignment #3
1- Description
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
ay a
into the pointer p. In other words, you need to
find the element at the index idx in a
ay a
and store its address into pointer p.
• You must understand and decide how the formal parameter list of your function should look
like.
2-2- main
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
myA
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
printing).
Good luck!
Answered Same Day Jun 17, 2021

Solution

Arun Shankar answered on Jun 18 2021
138 Votes
#include #include using namespace std;
*
The getIndexAddress function :-
Input parameters :-
- Input a
, which is an a
ay of integers
- Input idx, which is an intege
- Input p, which is a pointe
Returns nothing. *
void getIndexAddress(int a
[], int idx, int**...
SOLUTION.PDF

Answer To This Question Is Available To Download

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here