Okay, I got abotu 5 problems solved today and I am on the hardest part! Basically my code ask the user to enter series of random numbers and then use sentinel to mark the end of numbers needed to be entered. Now I want to be able to tell my user the largest and the smallest number she/he entered. Is there a function that can do this? like a sort or something? Here's my code:
//This program lets the user enter series of random numbers
//Enter -99 to end the series
//Display the largest and smallest number entered
#include <iostream>
using namespace std;
int main ()
{
//declare variables
int numCount = 1; // number counter
int numbers; //to hold the numbers entered
int numAccum; // accumulator
//ask for number inputs
cout << "Please enter random numbers\n";
cout << "I will sort them out and tell you\n";
cout << "the largest and the smallest number you entered\n";
cout << "When you are done just enter -99 so I can process your inputs\n\n";
cout << "Enter random number " << numCount << ": ";
cin >> numbers;
//enter the sentinel -99 to end the number inputs
while (numbers !=-99)
{
numAccum += numbers;
numCount++;
cout << "Enter random number " <<numCount << ": ";
cin >> numbers;
}
//sort out the numbers and pull out the largest and the smallest
cout << "The largest number is: \n";
WHAT FUNCTION DO I USE HERE??? OR ANY jumpstart on looping this?
return 0;
}