Question: TASK 2 : In the function main, there are three comments that start with / * INSERT CODE HERE * / . Write code to
TASK : 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 ie use the new operator and finally deallocate the array.
TASK : Define the function readsize to prompt and input the size of the array from the user. If the entered size is not positive, then repeatedly reprompt the user.
TASK : Define the function readlist 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, ie 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 : Define the function displaylist 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, ie 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 : Define the function findmin 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, ie 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 findmin, 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 arraymax 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 findmin.
arraymax array; max A; for int i ; i n; i for i to n do if arrayi arraymax if Aimax then arraymax arrayi; max A; endif endfor The variable arraymax 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
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
