// Author: Brandon Mohawk // Teacher: Dr. Wang // Due: 02/07/07 // // Goal: Lets the user enter a series of numbers, followed by // -99 to signal the end of the numbers. The program then // displays the greatest and least of the numbers entered. // // File: greatestleast.cpp // Compile: g++ greatestleast.cpp -o greatestleast.out // Run: ./greatestleast.out #include using namespace std; const int M = 100; int getMax ( int[], int&); int getMin ( int[], int&); int input (int[]); int main() { int intArr[M]; int size = input (intArr); int max = getMax(intArr, size); int min = getMin(intArr, size); cout << "The lowest is " << min << " and the highest is "; cout << max < value) value = array[i]; } return value; } int getMin (int array[], int& size) { int value = array[0]; for (int i = 0; i < size; i++) { if (array[i] < value) value = array[i]; } return value; } int input ( int array[]) { int value; int size = 0; cout << "Input the numbers\n"; cin >> value; while (value != -99) { array[size] = value; size++; cin >> value; } return size; }