Outputting multiple values of same variable

I'm new to C++ and I'm having trouble understand how to output a "random" multiple valued integer. My program asks to input any number of integers and find the greatest and least of those integers. I have that down, but I don't know how to take the original integers and output them with my greatest and least numbers. Heres my code for the program.

#include <iostream>
using namespace std;

int main()
{

int num, greatest, least;

cout << "Type an integer that isn't -99\n";
cin >> num;

greatest = num, least = num;

while (num != -99)
{
if (num > greatest)
greatest = num;
else if (num < least)
least = num;

cout << "Type an integer that isn't -99\n";
cin >> num;
}

cout << "Least: " << least << endl;
cout << "Greatest: " << greatest << endl;
return 0;

}

This works completely fine, but where I'm outputting the least and greatest, how can I output inputted numbers? Say it woud look like
"You inputted 5, 6, 7, and 8"
and then here it would have the least greatest outputs That I already have. I haven't learned arrays which is what someone told me I could use, so what is there that I can do to output the inputs?
The only ones I see are arrays or vectors, with vectors being better since you don't know how many elements are stored. You might also be able to store them to a string or similar and append the values as you get them.
hmm, my book doesn't have vectors for quite a while. I don't know if my instructor worded the assignment badly or what. it says "The program output should display ALL THE NUMBERS ENTERED(yes it's in caps) plus the largest and smallest numbers entered." I'm assuming he wants me to output these numbers, instead of just having the numbers be input and shown on the screen somehow(This chapter is about loops) but I don't see how I can possibly do it without the array/vector people have mentioned.
As far as i knowthe only way to do that is to ether input the data into an aray as it is inputed or give each number inputed its own variable then just use cout to display each variable the problem with using the variables is that you are limited to how many numbers can be entered based on how many variables you set up ifyou want to leave it inan infinite loop like that i would look up arrays and figure out how to work it into your aplication vectors would work as well but normally i seepp using arrays for what you are doing is the programmeant to run in a infinite loop until you type -99 or is there a set amount of times the user should be abletoinput a number..
You could use a string to do it, just append every variable (and spaces) to it...but I would only do that if they are REALLY set on not letting you use arrays/vectors.
What do you mean by append every variable? We haven't learned arrays/vectors so we cannot use them as of now for this program. And the challenge asks to "Write a program with a loop that let's the user enter a series of numbers, followed by -99 to signal the end of the series. The program will display the largest and smallest numbers of the series" I'm positive it means an unlimited number of values, so unless theres a way to make a variable unlimited I don't understand how I'll do it. My instructor has his own sheet indicating more things that are needed to be included, which is what I quoted in my second post.
I.e.:

1
2
3
4
5
string String;
for(int i = 0; i < 5; ++i) {
   String.append(i); //append i to the string
   String.append(" "); //add a space for readability
}
how would u do a flowchart to this code u presented in the beginning im extremely horrible at making flowchart and want to see what i do wrong thnks

#include <iostream>
using namespace std;

int main()
{

int num, greatest, least;

cout << "Type an integer that isn't -99\n";
cin >> num;

greatest = num, least = num;

while (num != -99)
{
if (num > greatest)
greatest = num;
else if (num < least)
least = num;

cout << "Type an integer that isn't -99\n";
cin >> num;
}

cout << "Least: " << least << endl;
cout << "Greatest: " << greatest << endl;
return 0;

}
Topic archived. No new replies allowed.