Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Guess The Number V1.0 - A simple number guessing game,
- // produces a random number then prompts the user to enter their guess
- // Include the header files required
- #include <ctime>
- #include <cstdlib>
- #include <iostream>
- #include <string>
- // using namespace declaration
- using namespace std;
- // Main Program entry Point
- int main()
- {
- // Here we generate random numbers using the current time
- srand((unsigned int)time(NULL));
- // Next we get a random number between 0 and 200
- unsigned int numberToGuess = rand() % 201;
- // output a message to the user
- cout << "Choose a number between 0 & 200 : " << endl;
- // variable to hold the user's value
- unsigned int userNumber;
- // output message to user
- cout << "You're Guess? : ";
- // this will store the users number
- cin >> userNumber;
- // output the results to the console
- cout << "You guessed : "
- << userNumber
- << endl
- << "The actual number was : "
- << numberToGuess
- << endl << endl;
- // get input from user before closing the window
- system("pause");
- // let the program know we have finished without error and exit
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement