{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

Average

# Average - cout<< y[i<<"" cout<< endl...

This preview shows page 1. Sign up to view the full content.

// Determine the number of elements in an array // greater than the average // Author: Chuck Swanson, modifications by Eric Van Wyk. #include<iostream> using namespace std; int main() { const int NEL = 10; int i, count = 0; double avg = 0.0; //declare and initialize an array double y[] = {88.7, 77.9, 84.3, 99.2, 56.7, 65.5, 70.2, 80.5, 91.5, 55.8}; // display the array for(i=0; i < NEL; i++) {
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: cout << y[i] << " " ; } cout << endl; // get the average double sum = 0.0 ; for(i=0; i < NEL; i++) { sum += y[i]; } avg = sum / NEL; cout << "Average = " << avg << endl; // determine the number greater than the average for(i=0; i < NEL; i++) { if( y[i] >= avg ) count++; } cout << "There are " << count << " elements greater than the average\n"; return 0; }...
View Full Document

{[ snackBarMessage ]}

### What students are saying

• As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

Kiran Temple University Fox School of Business ‘17, Course Hero Intern

• I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

Dana University of Pennsylvania ‘17, Course Hero Intern

• The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

Jill Tulane University ‘16, Course Hero Intern