Question: TASK 2 : In the function main, there are three comments that start with / * INSERT CODE HERE * / . Write code to

TASK 2: In the function main, there are three comments that start with /* INSERT CODE HERE */. Write code to satisfy the directions given in the comments below the comment /* INSERT CODE HERE */. You will declare a pointer variable called list, allocate an array into this variable using dynamic memory allocation (i.e., use the new operator), and finally de-allocate the array.
TASK 3: Define the function read_size to prompt and input the size of the array from the user. If the entered size is not positive, then repeatedly re-prompt the user.
TASK 4: Define the function read_list that will prompt and input from the user each element to be stored in the dynamically allocated array. Use pointer arithmetic (see the lecture notes on Pointers) to access the array elements in your solution.
You will use the dereference operator, i.e.*, and use the first input parameter as a pointer variable.
Note DO NOT use square bracket notation to access elements in the array. Using square bracket notation in your solution will receive no credit.
TASK 5: Define the function display_list that will display the array elements to the screen as a comma separated list. Use pointer arithmetic to access the array elements in your solution.
You will use the dereference operator, i.e.*, and use the first input parameter as a pointer variable.
Note DO NOT use square bracket notation to access elements in the array. Using square bracket notation in your solution will receive no credit.
TASK 6: Define the function find_min that will search for the smallest (minimum) element in the array. Use pointer arithmetic to access the array elements in your solution.
You will use the dereference operator, i.e.*, and use the first input parameter as a pointer variable.
Note DO NOT use square bracket notation to access elements in the array. Using square bracket notation in your solution will receive no credit.
HINT: To help you write your solution for function find_min, please study the following algorithm below that finds the maximum value in the array of integers (variable array), where variable n is the size of the array. This example is found in your lecture notes. The variable array_max will hold the maximum value in the array. Though this code uses square bracket notation, remember that you CANNOT use square bracket notation in your implementation of the function find_min.
array_max = array[0]; //1. max A[0]; for (int i =1; i < n; i++)//2. for i=1 to n-1 do { if (array[i]> array_max)//3. if (A[i]>max) then { array_max = array[i]; //4. max A[0]; }//5. endif }//6. endfor // The variable array_max will contain the maximum value in the array

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!