Starting from:

$25

CSCI251-Lab Task 4 Pointer Arithmetic and Dynamic Arrays Solved

Question 1 (Pointer Arithmetic)
 

Write a program that performs the following:

 

Declare and randomly populate an array of integers with 20 positive numbers not greater than 100. The program should determine the median of the array. When a set of values is sorted in ascending or descending order, its median is the middle value. If the set contains an even number of values, the median is the mean, or average, of the two middle values. You are required to use a temporary array for the sorting. The original array should not be changed. Display the original array, the sorted array, and the median.

 

For this task, you are required to use only pointer notation and pointer arithmetic instead of array notation.  

 

 

Question 2 (Dynamic Arrays)
 

Write a C++ program that performs the following:

 

1.     Request for the number of inputs the user will enter.

2.     Dynamically create an array of integers using the input required above.

3.     Let the user enter all the integers in the array (allow duplicates).

4.     Pass the array to a function that will remove all duplicates form the array. Un-used elements should be removed and the new size should be returned back to main. Use only pointer notation to do this.  

5.     The main() function then display the content of the new array.

 

Example input/output is shown below:

More products