Finding the Lowest and Largest Numbers

Alright, here is the problem

Write a program with a loop that lets the user enter a series of integers. The user should enter -99 to signal the end of the series. After all the numbers have been entered, the program should display the largest and smallest numbers.


I used a for loop to let the user enter their numbers, and i have it set so that when -99 is entered, it ends it, however, my problem lies in whether i need to add something to this loop, or do something else entirely.

I dont have any clue as to how i can find out which number was the largest and which was the smallest,here is my code so far.

Any Help would be greatly appreciated.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
#include<iostream>
using namespace std;

int main()
{
	int UserNumber;
	int UserChoiceCount = 1;

	cout << "The Greatest and Least of These.\n\n";
	cout << "Please enter as many numbers as you like, when you \n";
	cout << "are done I will show you the largest and smallest of \n";
	cout << "the numbers you entered.\n\n";

	for (int count = 0; count < 1; UserChoiceCount++)
	{
	
		cout << UserChoiceCount << ") enter a number \n";
		cout << "(enter -99 when you are done) \n"; 
		cin >> UserNumber;
		cout << "\n\n";
		if (UserNumber == -99)
			break;

	}
Topic archived. No new replies allowed.