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.
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.
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
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 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>
3 using namespace std;
4
double centeredAverage(const double a[], size t len)
6 {
5
7
8
9
10 }
Demo.cpp
1 #include <iostream>
2 using namespace std;
3
4
#include "arrays.h"
int main()
{
double al[] = {13.4,6.5,8.4,6.7,10.9,8.2,2.2,10.5,4.9};
print("al->", al, 9);
cout « "centeredAverage: " «
cout « endl;
6
7
8
10
« centeredAverage(al, 9) « endl;
11
12
13
double a2[] = {12.6,13.4,23.4,9.5,5.9,15.5,14.4,5.3,22.0,15.1};
print ("a2->", a2, 10);
cout « "centeredAverage: " « centeredAverage(a2, 10) « endl;
cout « endl;
14
15
16
17
double a3[] = {10.1,22.7,17.4};
print("a3->", a3, 3);
cout « "centeredAverage: " « centeredAverage(a3, 3) « endl;
cout « endl;
18
19
20
21
22
23
double a4[] = {9.3,18.5,6.7,20.4,16.5,8.6,20.4,8.5,13.3,13.8, 19.9,6.4,20.3,6.1};
print ("a4->", a4, 14);
cout « "centeredAverage: " «
cout « endl;
24
25
« centeredAverage(a4, 14) « endl;
26
27 }
CodeCheck
Reset](/v2/_next/image?url=https%3A%2F%2Fcontent.bartleby.com%2Fqna-images%2Fquestion%2F79920f54-6dd5-4f69-b3b3-91d2ebf645a4%2Fe8d7e903-7d19-466a-8cc8-a238a14824a8%2F3zrltn_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>
3 using namespace std;
4
double centeredAverage(const double a[], size t len)
6 {
5
7
8
9
10 }
Demo.cpp
1 #include <iostream>
2 using namespace std;
3
4
#include "arrays.h"
int main()
{
double al[] = {13.4,6.5,8.4,6.7,10.9,8.2,2.2,10.5,4.9};
print("al->", al, 9);
cout « "centeredAverage: " «
cout « endl;
6
7
8
10
« centeredAverage(al, 9) « endl;
11
12
13
double a2[] = {12.6,13.4,23.4,9.5,5.9,15.5,14.4,5.3,22.0,15.1};
print ("a2->", a2, 10);
cout « "centeredAverage: " « centeredAverage(a2, 10) « endl;
cout « endl;
14
15
16
17
double a3[] = {10.1,22.7,17.4};
print("a3->", a3, 3);
cout « "centeredAverage: " « centeredAverage(a3, 3) « endl;
cout « endl;
18
19
20
21
22
23
double a4[] = {9.3,18.5,6.7,20.4,16.5,8.6,20.4,8.5,13.3,13.8, 19.9,6.4,20.3,6.1};
print ("a4->", a4, 14);
cout « "centeredAverage: " «
cout « endl;
24
25
« centeredAverage(a4, 14) « endl;
26
27 }
CodeCheck
Reset
Expert Solution

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

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