do-while loop...I think.

I need to do a do-while loop as my for loops keep track of the numbers. Example: How many numbers would you like? 7
1, 2, 3, 4, 5, 6, 7
How many more numbers would you like? 8
8, 9, 10, 11, 12, 13, 14, 15.

and so on...
Just not sure where and how to put the loop.

Cheers,
Ryan

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
  //  doStuff.cpp

#include "doStuff.h"
#include "Tools.h"

#include<iostream> 
using namespace std;


void doStuff(void)
{
    int userNumbers;
    getUserInput(userNumbers);
    getDigit(userNumbers);

}

void getUserInput(int &userNumbers)
{
    userNumbers = getPositiveInt("How many really interesting numbers would you like to see? ");
}

void getDigit(int userNumbers)
{
    for (int myNumber  = 0; myNumber <= userNumbers; ++myNumber )
    {
        if (myNumber % 10 == 4)
            cout << myNumber << endl;
        if (myNumber / 10 == 4)
            cout << myNumber << endl;
    }
}
You can use a dynamic array to store the user's input in.
Using a dynamic array you can declare something like int *array which is a pointer. Then you prompt the user for their input, for example
1
2
3
4
5
6
7
8
cout<<"How many numbers would you like? ";
cin>>number;
array=new int[number];
cout<<"Please enter your number(s): ";
for(i=0; i<number; i++)
{
    cin>>number[i];
}

Then the array hold all of their numbers entered.
Topic archived. No new replies allowed.