//Cameron Pham             CS1A                       Chapter 7, p. 444, #2
//
/***************************************************************
* DISPLAY LARGEST AND SMALLEST ARRAY VALUES
****************************************************************
* This program accepts 10 float values from the user and stores them
* in an array. It then determines and displays the largest and
* smallest values stored in the array.
* ______________________________________________________________________________
* INPUT:
* Values       // The 10 numbers entered by the user
*
* OUTPUT:
* Largest      // The largest value in the array
* Smallest     // The smallest value in the array
****************************************************************/

#include <iostream>
using namespace std;

int main()
{
    // Initialize variables
    float values[10];       // Stores the 10 numbers
    float largest;          // Stores the largest number
    float smallest;         // Stores the smallest number

    // Ask the user to enter 10 numbers
    for (int i = 0; i < 10; i++)
    {
        cout << "Enter value #" << (i + 1) << ": ";
        cin >> values[i];
    }

    // Initialize the largest and smallest values
    // using the first element in the array
    largest = values[0];
    smallest = values[0];

    // Search the array for the largest and smallest values
    for (int i = 1; i < 10; i++)
    {
        if (values[i] > largest)
        {
            largest = values[i];
        }

        if (values[i] < smallest)
        {
            smallest = values[i];
        }
    }

    // Display the results
    cout << endl << "Largest value: " << largest << endl;
    cout << "Smallest value: " << smallest << endl;

    return 0;
}