Return the centered average of an array, which is the mean average of the values, ignoring the largest and smallest. If there are multiple copies of the smallest or largest values, ignore just one. If the length is less than 3, then return 0. array You may use a loop, or the algorithms in the standard library. arrays.cpp #include #include 1 2 3 using namespace std; 4 double centeredAverage(const double a[], size_t len) { 7 8.

Microsoft Visual C#
7th Edition
ISBN:9781337102100
Author:Joyce, Farrell.
Publisher:Joyce, Farrell.
Chapter6: Using Arrays
Section: Chapter Questions
Problem 19RQ
icon
Related questions
Question

C++

Return the centered average of an array, which is the mean average of the values, ignoring the largest
and smallest. If there are multiple copies of the smallest or largest values, ignore just one. If the
length is less than 3, then return 0.
array
You may use a loop, or the algorithms in the standard library.
arrays.cpp
1
#include <algorithm>
2
#include <numeric>
3
using namespace std;
4
double centeredAverage(const double a[], size t len)
{
6.
7
9.
10
Demo.cpp
1
#include <iostream>
2
using namespace std;
3
4
#include "arrays.h"
int main()
{
double al[] = {8.7,5.3,1.2,3.8,12.2};
print("al->", al, 5);
cout « "centeredAverage:
cout « endl;
7
10
« centeredAverage(al, 5) « endl;
11
12
double a2[] = {14.6,15.9,13.4,22.7};
print("a2->", a2, 4);
cout « "centeredAverage: " <« centeredAverage(a2, 4) <« endl;
cout « endl;
13
14
15
16
17
double a3[] = {6.5,11.4,23.0,10.4};
print("a3->", аз, 4);
cout « "centeredAverage: " <« centeredAverage(a3, 4) << endl;
cout « endl;
18
19
20
21
22
double a4[] = {17.8,17.6,24.1,22.5};
print("a4->", a4, 4);
cout « "centeredAverage: " <« centeredAverage(a4, 4) <« endl;
cout « endl;
}
23
24
25
26
27
CodeCheck
Reset
Transcribed Image Text:Return the centered average of an array, which is the mean average of the values, ignoring the largest and smallest. If there are multiple copies of the smallest or largest values, ignore just one. If the length is less than 3, then return 0. array You may use a loop, or the algorithms in the standard library. arrays.cpp 1 #include <algorithm> 2 #include <numeric> 3 using namespace std; 4 double centeredAverage(const double a[], size t len) { 6. 7 9. 10 Demo.cpp 1 #include <iostream> 2 using namespace std; 3 4 #include "arrays.h" int main() { double al[] = {8.7,5.3,1.2,3.8,12.2}; print("al->", al, 5); cout « "centeredAverage: cout « endl; 7 10 « centeredAverage(al, 5) « endl; 11 12 double a2[] = {14.6,15.9,13.4,22.7}; print("a2->", a2, 4); cout « "centeredAverage: " <« centeredAverage(a2, 4) <« endl; cout « endl; 13 14 15 16 17 double a3[] = {6.5,11.4,23.0,10.4}; print("a3->", аз, 4); cout « "centeredAverage: " <« centeredAverage(a3, 4) << endl; cout « endl; 18 19 20 21 22 double a4[] = {17.8,17.6,24.1,22.5}; print("a4->", a4, 4); cout « "centeredAverage: " <« centeredAverage(a4, 4) <« endl; cout « endl; } 23 24 25 26 27 CodeCheck Reset
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 2 steps with 1 images

Blurred answer
Knowledge Booster
Function Arguments
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Microsoft Visual C#
Microsoft Visual C#
Computer Science
ISBN:
9781337102100
Author:
Joyce, Farrell.
Publisher:
Cengage Learning,