Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- int main()
- {
- start:
- int randomNumber = (rand() % 101);
- int guess;
- cout << "Number guessing game" << endl;
- cout << "********************" << endl;
- cout << "The random number has been generated; it's between 1-100" << endl;
- play:
- cout << "Guess: ";
- cin >> guess;
- if(guess == randomNumber)
- {
- cout << "Correct, play again.." << endl;
- system("pause");
- goto start;
- }
- else if(guess < randomNumber)
- {
- cout << "Wrong, the random number is greater" << endl;
- goto play;
- }
- else if(guess > randomNumber)
- {
- cout << "Wrong, the random number is less" << endl;
- goto play;
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement