// Andres Guzman CSC5 Chapter 7, P. 444, #1
/******************************************************************************
*
* DISPLAY SUBSCRIPT VALUES
* ____________________________________________________________________________
* Program will take inputs from programmer and the display the highest and
* lowest values from the subscript.
* ____________________________________________________________________________
*
* INPUT
*
* [SIZE] = Array Size
* array[SIZE] = Subscript to hold input values.
*
* OUTPUT
*
* highest = Largest input value
* lowest = Lowest input value
*
******************************************************************************/
#include <iostream>
using namespace std;
int main()
{
const int SIZE = 10; //Array Size
int array[SIZE]; //Array Subscript
int i; //Counter
//Initilalizing For Loop to enter Value.
for(i = 0; i < SIZE; i++)
{
cout << "Enter a Value: ";
cin >> array[i]; //Allows input value and adds inputted Value into
//subscript.
cout << endl;
}
//Initializing Variables post input loop
int highest = array[0]; //Assigns highest value to subscript 0
int lowest = array[0]; //Assigns lowest value to subscript 0
//Creating For Loop to find highest and lowest input value
for(i = 0; i < SIZE; i++)
{
if(array[i] > highest) //Cycles through subscipt to find greater than 0
highest = array[i]; //Assigns found subscript to highest variables
if(array[i] < lowest) //Cycles through subscript to find lesser than 0
lowest = array[i]; //Assigns found subscript to lowest variable
}
cout << "Largest Value: " << highest << endl;
cout << "Smallest Value: " << lowest;
return 0;
}