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 »
need help with this


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 return anything (the return type is void). The input arguments are as follows: - Input arr, which is an array of integers - Input idx, which is an integer - Input p, which is a pointer This function puts the address of index idx of array arr into the pointer p. In other words, you need to find the element at the index idx in array arr 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 array of integers with size 20. Call it myArray 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 myArray to ptr pointer, where i is the input integer value that the user provided. - Write some code to show the correctness of your function and program (also use proper message printing). Good luck!
Answered Same DayJun 17, 2021

Answer To: CS202 Computer Science II Assignment #3 1- Description In this assignment, we want to test our...

Arun Shankar answered on Jun 18 2021
138 Votes
#include
#include
using namespace std;
/*
The getIndexAddress function :-
Input parameters :-
- Input arr, which is an array of integers
- Input idx, which is an integer
- Input p, which is a pointer
Returns nothing. */
void getIndexAddress(int arr[], 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