#include <iostream> using namespace std; const int SENTINEL = -99; int greatest(int i); int smallest(); int main () { // Declaring variables char letter; //letter chosen from the menu int i; //quantity of numbers user will enter int counter; //loop control variables int num; // variable to store new number int largest; // variable to store largest number int least; // Initializing variables largest = -9999999; least = 9999999; // Big loop here for the condition of the Application running do { //displaying Menu cout << "Please Select One of the Following Choices" << endl; cout << "A: Find the largest number with a known quantity of number " << endl; cout << "B: Find the smallest number with an unknown quantity of number " << endl; cout << "C: Quit" << endl; cout << "Please enter your choice: "; cin >> letter; cout << endl; switch (letter) { case 'A': case 'a': cout << "How many numbers would you like to enter"<< " "; cin >> i; cout << endl; cout << "Please enter your numbers" << endl; cin >> num; cout << "The largest number you entered is" << " " << greatest(i); cout << " "; cout << endl; break; case 'B': case 'b': cout << "Please enter your numbers with your last number being" << " " << SENTINEL << endl; cin >> num; while (num != SENTINEL) { cout << smallest(); } cout << "The smallest number you entered is" << " " << smallest() << endl; } } while (letter != 'C' && letter != 'c'); cout << endl; return 0; } int Greatest(int i) { int large; int num; int count; large = -999999; // Initialize final result variable to largest number possible for (count = 0, count <= i, count++;) // start a loop, increment from 0 to count { cin << num;// Read next number if num > large // Compare number to final result variable large = num; // if number is greater than final result variable, then // store in final result variable } // end of loop return large;// return final result }// end of function greatest smallest() { least = 9999999 // Initialize final result variable to smallest number possible int num, int least; // Declare all variables while (number != SENTINEL) { if (num < least) //code for smallest goes here least = num; cin >> num; } return least; }

This post has been edited by **qazwsxed22**: 15 February 2009 - 05:19 PM