Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <ctime>
- #include <cstdlib>
- using namespace std;
- int main()
- {
- srand((unsigned)time(NULL));
- int randomNumber = rand() % 101;
- int tries, guess = 0;
- do
- {
- cout << "Try to get the random number." << endl;
- cin >> guess;
- tries++;
- if(guess > randomNumber)
- {
- cout << "Too high!" << endl;
- }
- else if(guess < randomNumber)
- {
- cout << "Too low!" << endl;
- }
- else if(guess == randomNumber)
- {
- cout << "Correct, you made it in " << tries << " tries." << endl;
- system("pause");
- }
- }while(guess != randomNumber);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement