
Database System Concepts
7th Edition
ISBN: 9780078022159
Author: Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher: McGraw-Hill Education
expand_more
expand_more
format_list_bulleted
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](https://content.bartleby.com/qna-images/question/79920f54-6dd5-4f69-b3b3-91d2ebf645a4/e8d7e903-7d19-466a-8cc8-a238a14824a8/3zrltn_thumbnail.png)
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 stepSolved 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.Similar questions
- Design this pattern in c++ **** **arrow_forwardIN THE C PROGRAMMING LANGUAGE j = 15; k = 9 // what are the values for n,m,and p after these operations: --j ; k++ ; n = j - ++k; m = j-- + k--; p = k + j;arrow_forwardEvaluate the following arithmetic expression as the C++ system would evaluate it. 12 /4 3 * 2arrow_forward
- Exercise 3: ● Comments in C++ are written with special characters. Insert the missing parts: How to Make this a single-line comment And Make this a multi-line comment SME Exarcica A:arrow_forwardC program, similar question from the book C how to program eighth edition question 4.14 but the problem add the -1arrow_forwardQ2:C has many statements for decisions and loops, while MIPS has few. What are the pros and cons for having more or less decision/loop statements? Please give several detailed examples.arrow_forward
arrow_back_ios
arrow_forward_ios
Recommended textbooks for you
- Database System ConceptsComputer ScienceISBN:9780078022159Author:Abraham Silberschatz Professor, Henry F. Korth, S. SudarshanPublisher:McGraw-Hill EducationStarting Out with Python (4th Edition)Computer ScienceISBN:9780134444321Author:Tony GaddisPublisher:PEARSONDigital Fundamentals (11th Edition)Computer ScienceISBN:9780132737968Author:Thomas L. FloydPublisher:PEARSON
- C How to Program (8th Edition)Computer ScienceISBN:9780133976892Author:Paul J. Deitel, Harvey DeitelPublisher:PEARSONDatabase Systems: Design, Implementation, & Manag...Computer ScienceISBN:9781337627900Author:Carlos Coronel, Steven MorrisPublisher:Cengage LearningProgrammable Logic ControllersComputer ScienceISBN:9780073373843Author:Frank D. PetruzellaPublisher:McGraw-Hill Education

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