Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <stdlib.h>
- #include <time.h>
- using namespace std;
- int main()
- {
- int g, n;
- play:
- srand (time(NULL));
- n = rand() % 20 + 1;
- system("cls");
- cout << "Number Guessing Game" << endl;
- cout << "*****************" << endl;
- cout << endl;
- cout << "The random number been generated" << endl;
- system("pause");
- while (g!=n)
- {
- system("cls");
- cout << "Number Guessing Game" << endl;
- cout << "********************" << endl;
- cout << "Guess: ";
- cin >> g; //Cin takes the input of user and stores it into the variable g
- }
- system("cls");
- cout << "You have found the number!" << endl;
- cout << "The number was " << n << endl;
- cout << "Press any key to play again" << endl;
- system("pause");
- goto play;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement