Database System Concepts
Database System Concepts
7th Edition
ISBN: 9780078022159
Author: Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher: McGraw-Hill Education
Bartleby Related Questions Icon

Related questions

Question

Using C++ Language

Modify the provided code as follows.
• Declare another array of the same size and type and call it above_average.
• Calculate the average height of the 12 students.
• In a loop of your choice, check if the height of an individual student is larger
than the average. If it is larger than the average, copy this element to the
above _average array.
Note that the above_average array will most likely have a smaller number of
elements than the original height array. This also means that the locations of
a specific student’s height in the two arrays may not be the same after copying.
So, you will need a separate counter to keep track of elements in the new array.
• Display the content of the new array as well as the average with suitable
prompt.

code so far:

#include <iostream>
using namespace std;

int main()
{
const int SIZE=12;
int sumHeight=0;
int height[SIZE];
int above_average[SIZE];
double average;

for(int i=0;i<SIZE;++i)
{
cout<<"Enter height in inches of student #"<<i+1<<": ";
cin>>height[i];
sumHeight+=height[i];
}

average = sumHeight/12;
//in a loop, check if height is above average
//copy to above_average array if it is


cout<<"You entered: "<<endl;
for(int i=0;i<SIZE;++i)
{
cout<<height[i]<<", ";
}
cout<<endl;


cout<<"Average is: "<<average<<endl;
for (//enter "above average" code here
{
cout<<"Above average: "<<above_average<<endl;
}
return 0;
}

Expert Solution
Check Mark
Knowledge Booster
Background pattern image
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
    Recommended textbooks for you
    Text book image
    Database System Concepts
    Computer Science
    ISBN:9780078022159
    Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
    Publisher:McGraw-Hill Education
    Text book image
    Starting Out with Python (4th Edition)
    Computer Science
    ISBN:9780134444321
    Author:Tony Gaddis
    Publisher:PEARSON
    Text book image
    Digital Fundamentals (11th Edition)
    Computer Science
    ISBN:9780132737968
    Author:Thomas L. Floyd
    Publisher:PEARSON
    Text book image
    C How to Program (8th Edition)
    Computer Science
    ISBN:9780133976892
    Author:Paul J. Deitel, Harvey Deitel
    Publisher:PEARSON
    Text book image
    Database Systems: Design, Implementation, & Manag...
    Computer Science
    ISBN:9781337627900
    Author:Carlos Coronel, Steven Morris
    Publisher:Cengage Learning
    Text book image
    Programmable Logic Controllers
    Computer Science
    ISBN:9780073373843
    Author:Frank D. Petruzella
    Publisher:McGraw-Hill Education