It works, but im just wondering if there is an easier / better way to do it.
also, i used the pause command, which waits for you to press a key to continue.
is there any command to make it wait 5 secs and then continue automaticly?
Code:
// Guessing Game
#include <iostream>
#include <ctime>
using namespace std;
int main()
{
int rNumber; // Random number variable
int Guess; // Your input variable
cout << "Welcome to Reece's, Guess the number game...\n\n\n\n\n";
// random number
srand(time(NULL));
rNumber = rand() % 15 + 1;
for ( ;; )
{
cout <<"Enter your answer: ";
cin >> Guess;
system("cls");
if ( Guess == rNumber )
{
cout <<" CONGRATS\n\n\n\n";
break;
}
if ( Guess > 0 && Guess < 15 )
{
cout << "Nope, wrong answer...\n";
system("PAUSE");
system("cls");
}
else
{
cout <<"ERROR! Enter a number above 0 but below 15.\n";
system("PAUSE");
system("cls");
}
}
cout << "The answer is " << rNumber << endl;
system("PAUSE");
return 0;
}