Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

(For the following assignment, please answer in the most SIMPLEST FORM possible.

ID: 3729509 • Letter: #

Question

(For the following assignment, please answer in the most SIMPLEST FORM possible. Nothing too intricate as I am only a beginner. THANK YOU) C++ LANGUAGE PLEASE!!

Exercise 11
Write a function that takes an array a of integers and its size n and returns the average of the remaining elements after discarding the minimum and maximum values from the array. If the minimum value appears more than once, only one instance of the minimum value is discarded. The same applies when discarding the maximum value.

Exercise 12
Redo exercise 11 using vectors.

Explanation / Answer

float average(int arr[], int n){
   int min = arr[0],max = arr[0];
   float avg = arr[0];
   for(int i = 1;i<n;i++){
       if(min > arr[i]){
           min = arr[i];
       }
       if(max<arr[i]){
           max = arr[i];
       }
       avg = arr[i];
   }
   cout<<avg;
   avg = avg - min - max;
   return avg/(n-2);
}