/*******************************************************************************
* Aiden Stannard // CS1A // Chapter 7 Homework: Challange 1# // 10/30/2026
*
* Largest/Smallest Value
*
* This program recieves 10 values, stores those values in an array of 10
* elements, and displays the largest and smallest values of the array. The
* program does not accept negative values.
*
* Input
* Enter 10 numbers: ___
* Output
* The largest number in the array is ___
* The smallest number in the array is ___
******************************************************************************/
#include <iostream>
using namespace std;
int main()
{
const int size = 10; // Value for the size of the array
double array[size]; // array definition
double large; // stores largest and smallest values assigned to the array
double small;
cout << "Enter 10 numbers; " << endl;
cin >> array[0];
// initializes large/small to be the first number entered int the array
large = array[0];
for (int count = 1; count < size; count++)
{
cin >> array[count];
while (array[count] < 0) // denies input if negative until a valid number is entered
{
cout << "You cannot enter a negative number. Re-enter number: " << endl;
cin >> array[count];
}
if (array[count] > large) // updates the smallest and largest number of the array
large = array[count];
if (array[count] < small)
small = array[count];
}
cout << "The largest number in the array is " << large << endl;
cout << "The smallest number in the array is " << small << endl;
return 0;
}