/* testarr05.cpp CIS 150 06/19/2008 David Klick Demonstrations of: initializing an array displaying an array summing an array getting an average value for an array finding an array's minimum value finding an array's maximum value */ #include #include using std::cin; using std::cout; void cont(); int main() { const int ARRAY_SIZE = 10; int nums[ARRAY_SIZE]; int ctr; int sum, min, max; double average; // seed the random number generator srand(time(0)); // initialize the array to random numbers for (ctr=0; ctr max) max = nums[ctr]; } cout << "The largest value is " << max << '\n'; cont(); return 0; } /* void cont(); Arguments: none Returns: nothing Clears input buffer and pauses waiting for user to press Enter. */ void cont() { if (cin.rdbuf()->sungetc() != -1 && cin.get() != '\n') cin.ignore(80,'\n'); cout << "Press enter to continue..."; cin.get(); } /* Sample output: The array contains: 81 20 85 96 80 93 84 69 1 40 The sum is 649 The average is 64.9 The smallest value is 1 The largest value is 96 */