IS this the best way to write this piece of code. or is there an easier way.
also could someone just post the small function that would work with it cuz i couldnt get it to work even though it looked fine.
cheers.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; cout <<"Enter your answer: \n"; cin >> Guess; if (Guess > 15 || Guess < 1) cout << "ERROR. Enter number above 0 and below 15 please: \n"; cin >> Guess; if(Guess == rNumber) cout << "Congrats You Win!\n"; else cout << "You lose!\n"; cout << "The Number is " << rNumber << endl; system("PAUSE"); return 0; }



LinkBack URL
About LinkBacks


