how to make guess function loop X number of times?

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
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <string>
using namespace std;
void guess();
void end();


int main ()
{
    guess();
    end();
}
void guess()
{
    int i =0;
    do
    {
        for( i = 0; i< 9; i++)
        {
            i++;
            int number;
            cout <<"Please enter any number except for the number 5"<<endl;
            cin >> number;

            if (number <= 4 || number >= 6)
            {
                guess();
            }
            else if(number == 5)
            {
                end();
            }
        }
    }
    while(i <= 9);

}

void end()
{
                    cout <<"I told you to not enter the number 5"<<endl;
                    abort();
}


how can i make the guess function limited to 10 times and then proceeds to end function?

i have both the do and for loops attempting to do the same thing?
Last edited on
nevermind

i figured it out myself...the function guess() keeps relooping by itself
Last edited on
Topic archived. No new replies allowed.