Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

In C++ please - 1. Arrays An array is basically of collection of related variables of the same type. For example, a collection of grades

In C++ please -

1. Arrays

An array is basically of collection of related variables of the same type. For example, a collection of grades of students, a collection of salary of employees of a company, etc. The following program allows the user to enter the height in inches of 12 students in a class and display their results.

image text in transcribed

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 bigger number of elements than the original height array. This also means that the locations of a specific students 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 a suitable prompt. It is recommended that you write an algorithm and try to solve the problem on paper before attempting to write the code.

#include using namespace std; int main() { const int SIZE=12; 1/12 students int sum_height=0; //variable for sum of heights int height [SIZE]; //array to store height of 12 students int above average [SIZE]; //store all above average heights in this array double average; //variable for average of heights for(int i=0;i>height[i]:// read heights, one student at a time //compute sum of heights } // compute average of heights //in a loop check if height is above average //copy to above_average array if it is cout

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Put Your Data To Work 52 Tips And Techniques For Effectively Managing Your Database

Authors: Wes Trochlil

1st Edition

0880343079, 978-0880343077

More Books

Students also viewed these Databases questions

Question

What is the expected effective yield of the investment portfolio?

Answered: 1 week ago

Question

Provide examples of Dimensional Tables.

Answered: 1 week ago