//Ryan Robateau CSC5 Chapter 7, P. 444, #1
//
/*******************************************************************************
* Compute Min and Max
* _____________________________________________________________________________
* This program allows the user to input values into an
* array and computes the largest and smallest values stored in
* the array.
* _____________________________________________________________________________
******************************************************************************/
#include <iostream>
using namespace std;
int main()
{
const int ARRAY_SIZE = 10;
int storage[ARRAY_SIZE];
int max; // INPUT - hold the highest number
int min; // INPUT - hold the lowest number
int count;
for (count = 0; count < ARRAY_SIZE; count++)
{
cout << "Please enter a value for index " << count + 1 << ":" << endl;
cin >> storage[count];
}
max = storage[0];
for (count = 0; count < ARRAY_SIZE; count++)
{
if (storage[count] > max)
max = storage[count];
}
min = storage[0];
for (count = 0; count < ARRAY_SIZE; count++)
{
if (storage[count] < min)
min = storage[count];
}
// OUTPUT RESULTS
cout << "\nThe largest number is: " << max;
cout << "\nThe smallest number is: " << min;
return 0;
}