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 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>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: "<
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;
}
Trending now
This is a popular solution!
Step by step
Solved in 2 steps