I have to print values entered in by the user, using a while loop and a sentinel value of -1 to indicate the end of the input. For example, if the inputs are "4 5 -1" then the output should be "INPUTS: 4 5". I'm not sure how to print all of the values out separately like a list.
This is what we were given to start with:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
#include <iostream>
usingnamespace std;
int main()
{
int num, sum;
cout << "INPUTS = ";
while ()
{
}
cout <<endl; return 0; //DO NOT DELETE
}
1. While the sentinel hasn't been reached..
2. Get input..
3. Output input...
When the sentinel is reached it will know to stop grabbing input, but it has to grab the sentinel as well in the buffer.. The sentinel doesn't just disappear.
Think about what you could put to prevent outputting the sentinel along with your numbers..
Think about this:
if you don't find the sentinel, then print out stuff. Otherwise don't do anything.