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?
#include <iostream>
#include <string>
#include <cstdlib>
#include <vector>
#include <ctime>
usingnamespace 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";
}
elseif(answer>x)
{
cout << "The answer is lower than that\n";
}
cout << "Enter your next answer: ";
cin >> answer;
}while (answer!=x);
}
#include <iostream>
#include <string>
#include <cstdlib>
#include <vector>
#include <ctime>
usingnamespace 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";
}
elseif (answer>x)
{
cout << "The answer is lower than that\n";
}
cout << "Enter your next answer: ";
cin >> answer;
} while (answer != x);
}