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 array length is less than 3, then return 0. You may use a loop, or the algorithms in the standard library. arrays.cpp
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 array length is less than 3, then return 0. You may use a loop, or the algorithms in the standard library. arrays.cpp
Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
Related questions
Question
![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 array
length is less than 3, then return 0.
You may use a loop, or the algorithms in the standard library.
arrays.cpp
1
#include <algorithm>
2
#include <numeric>
using namespace std;
4
double centeredAverage(const double a[], size_t len)
{
8
10
}
Demo.cpp
1
#include <iostream>
2
using namespace std;
3
4
#include "arrays.h"
6.
int main()
{
double al[] = {13.4,6.2,3.2,10.8,13.5,10.7,14.4,14.4,4.0,4.0,13.9,13.6,12.7,6.3,4.7};
print("al->", al, 15);
cout « "centeredAverage: " << centeredAverage(al, 15) « endl;
cout « endl;
7
8
10
11
12
double a2[] = {15.0};
print ("a2->", a2, 1);
cout « "centeredAverage:
cout « endl;
13
14
15
« centeredAverage(a2, 1) <« endl;
16
17
18
double a3[] = {7.1,11.1,5.9,17.1};
print("a3->", aз, 4);
cout « "centeredAverage: " « centeredAverage(a3, 4) « endl;
cout « endl;
19
20
21
22
double a4[] = {12.7};
print ("a4->", a4, 1);
cout « "centeredAverage:
cout « endl;
23
24
25
« centeredAverage (a4, 1) <« endl;
26
27](/v2/_next/image?url=https%3A%2F%2Fcontent.bartleby.com%2Fqna-images%2Fquestion%2Fe2932faa-b49a-4196-8420-f277821525a8%2F4f2fbfc9-8634-4856-bb78-ce62ff640788%2Fpsqnayr_processed.png&w=3840&q=75)
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 array
length is less than 3, then return 0.
You may use a loop, or the algorithms in the standard library.
arrays.cpp
1
#include <algorithm>
2
#include <numeric>
using namespace std;
4
double centeredAverage(const double a[], size_t len)
{
8
10
}
Demo.cpp
1
#include <iostream>
2
using namespace std;
3
4
#include "arrays.h"
6.
int main()
{
double al[] = {13.4,6.2,3.2,10.8,13.5,10.7,14.4,14.4,4.0,4.0,13.9,13.6,12.7,6.3,4.7};
print("al->", al, 15);
cout « "centeredAverage: " << centeredAverage(al, 15) « endl;
cout « endl;
7
8
10
11
12
double a2[] = {15.0};
print ("a2->", a2, 1);
cout « "centeredAverage:
cout « endl;
13
14
15
« centeredAverage(a2, 1) <« endl;
16
17
18
double a3[] = {7.1,11.1,5.9,17.1};
print("a3->", aз, 4);
cout « "centeredAverage: " « centeredAverage(a3, 4) « endl;
cout « endl;
19
20
21
22
double a4[] = {12.7};
print ("a4->", a4, 1);
cout « "centeredAverage:
cout « endl;
23
24
25
« centeredAverage (a4, 1) <« endl;
26
27
Expert Solution

This question has been solved!
Explore an expertly crafted, step-by-step solution for a thorough understanding of key concepts.
This is a popular solution!
Trending now
This is a popular solution!
Step by step
Solved in 2 steps with 3 images

Knowledge Booster
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.Recommended textbooks for you

Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education

Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON

Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON

Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education

Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON

Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON

C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON

Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning

Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education