//Roman Lara Delgado CSC5 Chapter 7, P.444, #1
//
/*******************************************************************************
*
* Determine The Largest and Smallest Value
*_______________________________________________________________________________
* This program determines the largest and the smallest value of a set of
* numbers.
* ______________________________________________________________________________
* INPUT
* value[SIZE] : entered values
*
* OUTPUT
* highest : The highest value of a set of numbers
* lowest : The lowest value of a set of numbers
*******************************************************************************/
#include <iostream>
using namespace std;
int main ()
{
/***************************************************************************
* CONSTANTS
* --------------------------------------------------------------------------
* SIZE : number of elements in the array
* *************************************************************************/
//Initialize Program Constants
const int SIZE = 10; //CONSTANT - number of elements in the array
//Declare Program Variables
int value[SIZE]; //INPUT - entered values
int highest; //OUTPUT - the highest value in the set of numbers
int lowest; //OUTPUT - the lowest value in the set of numbers
//Input Array Values
for (int count = 0; count < SIZE; count++)
{
cout << "Enter value #" << count + 1 << ": ";
cin >> value[count];
cout << endl;
}
//Determine Highest Value
highest = value[0];
for (int count = 1; count < SIZE; count++)
{
if (value[count] > highest)
{
highest = value[count];
}
}
//Determine Lowest Value
lowest = value[0];
for (int count = 1; count < SIZE; count++)
{
if (value[count] < lowest)
{
lowest = value[count];
}
}
//Output Highest and Lowest Value
cout << endl;
cout << "The highest value of the set is: " << highest << endl;
cout << "The lowest value of the set is: " << lowest << endl;
return 0;
}