Help with looping

I am having a difficult time creating loops in my programs. Attached is my program:

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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64

//variables and functions

using namespace std;
void description();
const int length = 20;
int seqSearch (const int list[], int listlength, int item);

int main()
{
//array and variables
int numList[] {42, 468, 335, 1, 170, 225, 479, 359, 463, 465, 206, 146, 282, 329, 462, 492, 496, 443, 328, 437};
int index;
int num;

description();

cout << "Caller, what is your number";
cin >> num;

//search for number. Needs to be sequential
int pos = seqSearch(numList, length, num);

//responses to if number is found
if (pos!=1)
    cout << "Correct Number.  Location is " << pos << endl;
 else

    cout << "Number not on List" << endl;

return 0;
}

//describes program
void description ()

{
    cout << "This program stimulates a radio station that asks the caller \n";
    cout << "to guess a number.  \nThe number is compared against a llist of 20 number \n";
    cout << "between 1 and 500 inclusive. \nThe contest is held until a number ";
    cout << "\n has been matched or a value of -1 is entered. \n \n" << endl;


}
//Program to find callers number in array
int seqSearch (const int list[], int listlength, int item)
{

    int loc;
    bool found = false;

    loc = 0;

    while (loc < listlength && !found)
    if (list[loc] == item)
    found = true;
    else loc++;

    if (found)
    return loc;
    else
    return -1;

}


My question is how do I create a loop which will:
1. count the number of callers
2. return to the question "Caller what is your number" if number is not found in array.

Any Help will be appreciated. Thanks
1. what callers?

2. put lines 16-29 into a do {} while( pos != -1 ); loop.
the "callers" is the question I ask for a number to guess (see line 18).
You mean you want to put the whole program in a loop? (I don't see what could be counted here)
Topic archived. No new replies allowed.