//Amari Mosley CSC5 Chapter 7, P. 444, #1
/***************************************************************
*
* COMPUTE LARGEST AND SMALLEST
* ____________________________________________________________
* This program lets the user enter 10 values into an array and
* displays the largest and smallest values stored in it.
*
* Computation is based on comparing array elements:
* if (values[count] > values[HighIndex])
* ___________________________________________________________
* INPUT*
* values: 10 integer values inputted by user through a loop
*
* OUTPUT*
* HighestValue: The largest value entered into the array
* LowestValue: The smallest value entered into the array
*
**************************************************************/
#include <iostream>
using namespace std;
int main() {
const int SIZE = 10;
int values[SIZE];
int HighIndex = 0;
int LowIndex = 0;
cout << "Enter 10 integer values:\n";
// Prompts user to enter values into the array
for (int count = 0; count < SIZE; count++) {
cout << "Value " << (count + 1) << ": ";
cin >> values[count];
}
// Calculates Highest and Lowest Values
for (int count = 1; count < SIZE; count++) {
if (values[count] > values[HighIndex]) {
HighIndex = count;
}
if (values[count] < values[LowIndex]) {
LowIndex = count;
}
}
// Output Complete Report
cout << endl;
cout << " \n LARGEST AND SMALLEST VALUES REPORT \n ";
cout << "Largest Value: " << values[HighIndex] << " \n ";
cout << "Smallest Value: " << values[LowIndex] << " \n ";
return 0;
}