Question: PLEASE DONT COPY ANYONE ELSES SOLVING AND LET BE ORIGINAL. Write a C++ code with the following specifications: - In the main function create an
PLEASE DONT COPY ANYONE ELSES SOLVING AND LET BE ORIGINAL.
Write a C++ code with the following specifications: - In the main function create an array with constant size of 20. (1mark)
- Create the following functions:
o fill(int a[],int size), the function should fill the array a[] with random numbers between 1-100 ( use rand() function) (2 marks)
o min(int a[], int size) return the minimum number in the array (2 marks)
o median(int a[], int size) return the median of the numbers in the array (2 marks)
o search(int a[], int size, int x) find and return the index of the first appearance of value x in the array. (2 marks)
o sumEvenIndex(int a[], int size) return the sum of the numbers that are in the Even indices in the array. (2 marks)
o sort(int a[], int size, int asc) sort the array ascending if asc=1, and descending otherwise. (3 marks)
o reverse(int a[], int size) that changes/swap the items in the array to be in reverse order. Example: if a={2,1,7,1,5} then it should become {5,1,7,1,2}. (3 marks)
o oddarray (int a[], int size) this function should remove all even values from the array and keeps only the odd numbers. (3 marks)
- Test all functions in the main. (5 marks)
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
