Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //Program uses time function to seed random number generator
- //and then generates random number
- #include <cstdlib>
- #include <ctime>
- #include <iostream>
- using namespace std;
- int main()
- {
- srand((unsigned)time(NULL));
- int d = rand()%12;
- cout << d;
- system("cls");
- play:
- int guess;
- cout << "Guess the random generated number: ";
- cin >> guess;
- if(guess == d)
- {
- cout << "You were right!" << d << "was right" << endl;
- }
- else
- {
- cout << "that was wrong try again" << endl;
- system("pause");
- goto play;
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement