Help

So I want to be able to plug in three numbers then leave and I am not sure what code I need to add in order to do that.

1
2
3
4
5
6
7
8
9
10
  void add_values ()
{ 
    cout << "Please add 10 numbers between 999 to -999." << endl;

    for(int i=0;i<10;i++)

        cin >> user_num[i];

    return;
What do you mean plug in three numbers then leave?
You have a for loop that runs 10 times and takes 10 inputs... so
So if a user only wanted to put in an initial 3 numbers and because a mistake was made needed to leave the add_values to edit but then subsequently wanted to return to finish putting in 7 more numbers
well im not really sure what your asking but u could create a a counter variable and have the user say how many values he wants to enter then use ur counter in the for loop
int counter;
cin >> counter;
for(int i = 0; i < counter; i++)
{}

or... you could have it where if the user inputs a somthing like "leave" then it will break the loop
Topic archived. No new replies allowed.