Not displaying my program

Made a simple program over a guess my number. It wont display any errors. The only thing it does is when I try build & run, it says: "It seems this project has not been built yet. Do you want to build it now?" I dont know whats wrong?


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
#include <iostream>
#include <string>
#include <cstdlib>
#include <vector>
#include <ctime>

using namespace std;


void game();


    int main()
    {
    cout << "Would you like to play?\n";
    string ans;
    cin >> ans;
    do
    {
        game();
    cout << "\nWould you like play again\n\n";
    cin >> ans;
    }while(ans=="yes" || ans=="Yes");

    }

void game()
{
            cout << "Welcome to guess my number!\n\n";
            int answer;
            int x = 1+rand()%100;
    do
    {
        cout << "Guess my number between 1-100, and ill tell you whether its lower or higher\nType 'Quit' to quit\n";
        cout << "Enter your guess: ";
        cin >> answer;

        if(answer < x)
        {
            cout << "\nThe answer is higher than that\n";
        }
        else if(answer>x)
        {
            cout << "The answer is lower than that\n";
        }

        cout << "Enter your next answer: ";
        cin >> answer;

    }while (answer!=x);

}
1.) I fixed your code so it will work.
2.) Look at this video, I am assuming you are using code:Blocks

https://www.youtube.com/watch?v=ASQ319OZzR0

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
#include <iostream>
#include <string>
#include <cstdlib>
#include <vector>
#include <ctime>

using namespace std;


void game();


int main()
{
	cout << "Would you like to play?\n";
	string ans;
	cin >> ans;
	do
	{
		game();
		cout << "\nWould you like play again\n\n";
		cin >> ans;
	} while (ans == "yes" || ans == "Yes");

}

void game()
{
	cout << "Welcome to guess my number!\n\n";
	int answer;
	int x = 1 + rand() % 100;
	
	cout << "Guess my number between 1-100, and ill tell you whether its lower or higher\nType 'Quit' to quit\n";
	cout << "Enter your guess: ";
	cin >> answer;
	
	do
	{
		if (answer < x)
		{
			cout << "\nThe answer is higher than that\n";
		}
		else if (answer>x)
		{
			cout << "The answer is lower than that\n";
		}

		cout << "Enter your next answer: ";
		cin >> answer;

	} while (answer != x);

}
Topic archived. No new replies allowed.