// File: WhileBoolFlagFunctionsSentinel.CPP // Sentinel Terminated; Functions with all Argument Types; // Boolean Flag; While Loop // Find the Extremes in a List of integers // Use a boolean flag to facilitate all data input into the program loop // Method of Iteration: for loop // Note that Data is always input directly before the sentinel is checked. #include #define False 0 #define True 1 #define Sentinel -999 using namespace std; // Read and Integer to Pass Back to the Caller void GetInteger(int &); // Update the Extremes if the Value Represents a New Extreme void UpdateExtremes(int,int &,int &); // Output the Results...Extremes or Message that No Data was Entered void Report(int,int,int); int main() {int Value,Min,Max,ExtremesInit=False; // Get the First Value GetInteger(Value); while (Value != Sentinel) { if (!ExtremesInit) { // Only Correct Method of Initializing Min and Max: // Set equal to initial Value Max=Min=Value; ExtremesInit=True; } else UpdateExtremes(Value,Min,Max); // Read subsequent Values At End of Iteration GetInteger(Value); } Report(Min,Max,ExtremesInit); return(0); } void GetInteger(int &Number) // Number: Output Only {cout << "Enter an Integer. Enter " << Sentinel << " to Quit >"; cin >> Number; } void UpdateExtremes(int N,int &Low,int &Hi) // N : Input Only {if (N>Hi) Hi=N; // Low, Hi: Input/Output else if (N